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
680
Column re-ordering issue
posted

I have a grid where I have a number of databound columns and then I add a single column which is not databound. I move that column to position 0:

grid.DisplayLayout.Bands[0].Columns["MyColumn"].Header.VisiblePosition = 0;

This works great.

I save the layout XML and in subsequent runs, I reload the layout. As the user can re-order columns, my intent is for whatever the last column layout was to be used.

The grid is bound to a BindingSource with a DataSource set to an array of objects which implement an interface.

In future executions, things go roughly as follows:

- I bind the grid to the BindingSource.
- I set the DataSource of the BindingSource to an empty array of the interface (_bindingSource.DataSource = new IMyInterface[0];)
- I load the layout from the XML file.

At this point, the Header.VisiblePosition for my column is properly set to 0.

- The user performs an action that loads data.
- The BindingSource.DataSource is set to the data which is an array of the objects implementing IMyInterface.

Immediately prior to setting the BindingSource.DataSource, the VisiblePosition. After that line executes, my column order gets changed and my unbound column is now the last column.


I have 3 other grids that operate under the same algorithm roughly and the other 3 operate properly. I can't figure out what I'm doing differently here.

I thought I could subscribe to AfterColPosChanged to see what's triggering the change, but it doesn't seem to ever get called except when e.PosChanged = PosChanged.Sized. Why is that?

Is there some way to know what's triggering the change in VisiblePosition?

Parents Reply Children
No Data