Hi,
I have a project where I use a number of UltraWinGrids version 6.2. On the majority of grids when I set the order of the columns in the designer they appear in code as expected (Header.VisiblePosition = x), however on grids used in a series of screens, despite the code appearing to be the same the columns appear in a different order than what is specified in the designer.
Ultimately I just need to know what is being changed in the grids that causes them to ignore the visible position property? The band is being added, the visible position property is set correctly in code. I don't see any code that would change the default grid setting, but I must be missing something. Any ideas?
It appears from the code that the visible position is being changed when the control is bound to the data in these lines of code:
this.bindingSource1.DataSource = objBO.VBOData.DataSet;
this.ultraGrid1.SetDataBinding(this.bindingSource1, null, true);
//band[0].columns["mycolumn"].Header.VisiblePosition = 7
One thing I did try after looking through the forums was:
{
//e.Dialog.ColumnChooserControl.ResetSyncLookWithSourceGrid();
}
This does set the colums to the correct order, but would take away a lot of the combo box functionality.
Thanks,
Trevor
(yes I have spent too much time on this issue just to move column positions)
Mike,
I agree that's probably the most likely possibility right now. Thank you for the thoughts.
Also, I believe the code does use the SetDataBinding method, it's not highlighted very well. The DataSource is set on the DataBinding object, then the DataBinding object is passed to the SetDataBinding method.
I used the InitializeLayout event and it worked like a charm. Thanks again.
Hi Trevor,
My guess is that your design-time grid has a different structure than the data source you are binding it to. If the band names are not the same, then when you bind the grid, it will blow away everything in the layout and create a new layout from the data source.
Also, you should not set the DataSource property of the grid, you should use the SetDataBinding method, instead.
Personally, I find it much easier to simply arrange the columns inside the InitializeLayout event of the grid. That way you don't have to worry about losing the layout.