Hello,
I have a grid where I set the column width in the InitializeLayout event. When I first bind a DataSet to the DataSource property the columns display with the correct width. However, if I rebind the DataSet the columns becomes smalle. Any subsequent bindings does not change the column width. Any explanations?
What exactly do you mean by "rebind the DataSet". It sounds to me like whatever youare doing it causing the data source to send a Reset notification to the grid, which means the grid has to throw away all existing columns and rows and re-load everything from scratch.
By rebind the dataset I mean:
myGrid.DataSource = null;
myGrid.DataSource = myDataSet;
I think I know what is causing the problem. When a grid has 2 bands (or more) the column width seems to be the combined width of the columns that are stacked on top of each other within the bands. The visual width of the column is different from the Width property of the column object. Any ideas why this is? Is it a bug?
DatL said:By rebind the dataset I mean: myGrid.DataSource = null; myGrid.DataSource = myDataSet; I think I know what is causing the problem.
I think I know what is causing the problem.
Well, there's no great mystery there. Setting the grid's DataSource to null and back is going to destroy all of the rows and the entire grid layout and then rebuild a completely new layout based on the new data source. Is the grid bound at design-time? If you adjust the column widths at design-time, they wll be maintained at run-time. But any and all layout settings in the grid will be lost when you do this code. Why are you doing this to the data source? Is this a new data set you are binding to, or the same one you were already binding to?
DatL said:When a grid has 2 bands (or more) the column width seems to be the combined width of the columns that are stacked on top of each other within the bands. The visual width of the column is different from the Width property of the column object. Any ideas why this is? Is it a bug?
I'm afraid I do not understand what you are decribing here. What's this about columns stacked on top of each other? Are you using RowLayouts or Groups and Levels?