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
85
VisiblePosition of UltraWinGrid Columns Not Updating
posted

I'm working on an application where we need to "remember" the order of the columns in an UltraWinGrid.  As the application is closing, I cycle through all of the columns in the grid and grab the visible position and then save all of the values to the database.  When the application is re-started, I get all of the visible positions from the database and loop through the columns of the grid to set the visible position of each column. 

The problem that I'm having is that the VisiblePosition property does not appear to be updating.  I've debugged the closing event of the application and checked the VisiblePosition of the columns, but they are the same as when the application started, ignoring any changes I had made.  Is this the best approach to follow?  If so, why would the property not be getting updated?  I've tried referencing the ColumnsCollection of the grid through Grid.DisplayLayout.Bands[0].Columns and Grid.Rows.Band.Columns and they function the same.

Thanks,  Ryan.

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

     Hi Ryan,

    Why not use the grid.DisplayLayout.Save/Load methods? That would save you a lot of code. 

    If you can't use those for some reason, then my guess is that you are probably setting the VisiblePosition on the columns either in the wrong event or in the wrong order. 

    I would recommend using the InitializeLayout event. When you set the VisiblePosition, make sure you set them in order from 0 up. Otherwise, you run the risk of setting the VisiblePosition on one column and having that affect the position of other columns. 

    So for example: 

    e.Layout.Bands[0].Columns["A"].Header.VisiblePosition = 0;

    e.Layout.Bands[0].Columns["B"].Header.VisiblePosition = 1;

    e.Layout.Bands[0].Columns["C"].Header.VisiblePosition = 2;

    e.Layout.Bands[0].Columns["D"].Header.VisiblePosition = 3;

    Another possibly issue here is if you are usnig RowLayouts. If you are, then the VisiblePosition property is not used because the column positions are determined by the RowLayoutInfo on the column. 

Children