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
115
Win Grid Column(s) Order Changing Unexpectedly
posted

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;

//band[0].columns["mycolumn"].Header.VisiblePosition = 4

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:

private void ultraGrid1_BeforeColumnChooserDisplayed(object sender, BeforeColumnChooserDisplayedEventArgs e)

{

  //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)

Parents
  • 469350
    Verified Answer
    Offline posted

     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.  

Reply Children