I am setting the VisiblePosition property of some grid columns from 0 to 5. These columns have been added to a multi level group. Columns 0 through 4 are on level 0, and 5 is on level 1. The order of the columns on level 0 is not obeying the order defined by the VisiblePosition property. How do I make the VisiblePosition work properly in a multi-level band group.
Hi Alkali,
I'm glad you got it sorted out. Incidentally, I wrote a little utility to help myself with cases like this. Basically, it's a little helper class where you set the positions on the columns in any order you want and it just stores them without applying them to the grid. Then when you are done setting all of the positions, it sorts them and applies them to the grid in the proper order.
I have attached it here in case you need it in the future.
The problem was caused by setting the VisiblePosition out of order, as it was set by iterating the column collection and setting the VisiblePosition based on the column key. Setting the position in order works.
Does it matter if you have two levels or not?
My first guess is that this is probably caused by the order in which you are setting the VisiblePosition. You must set the VisiblePosition in order from 0 to 4. Otherwise, you run the risk that setting the position of one column will alter the position of another column whose position was already set.
You probably need to set the Level on each column, first, also.
All of this is assuming that you are are using Groups and Levels (RowLayoutStyle = None). If you are using GroupLayout style, then VisiblePosition is irrelevant and you have to use the RowLayoutColumnInfo on each column to establish it's position.