Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
560
Define Layout in Designer, setting datasource at runtime
posted

Hello,

 I want to add a databound WinGrid to my form. The datasource will be set at runtime, but I would like to add columns in the design mode. So I manually define a schema with all the columns I would like to see. Am I right, that the key of a column will be the column name of the datatable that is used as datasource?

Whenever I set the datasource (grid.datasource = datatable), the columns created in the designer are dropped and the grid automatically creates the columns of the datasource. The datasource has more columns that I would like to show in the grid, will I have to create them in the schema in design mode or can I just left them out?

Just a small example: my datatable has the columns a, b, c and d, but I only want to show the columns a, b and c in the grid. So I defined a schema only for those columns. The header text is also set in the design mode. When setting the datasource at runtime, the column d will created even it is not defined in the schema of the grid and all header text will be replaced with the column name of the datasource.. Could you please give me a small introducion how to set a datasource without destroying the columns settings I set in design mode?

Thanks, Stefan

Edit: I solved this by myself using try and error :) First of all I found out that I have to use SetDataBinding so that I can hide columns which are not defined in the schema. Also the key of the child band is not the name of the child datatable, but the name of the datarelation between parent and child table.