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
480
Ability to control the order of the columns
posted

I understand there is no AutoGenerateColumn propery in the WinGrid (really sucks, makes more work). After databinding, I need to be able to go through a list of bound coulumns and move then appropriately based on a an array of keys. I have tried the Column SWAP functionality and it is really not functioning properly for me (logic may be wrong). Is there any snip of code IG might have to show this functionality.

  • 469350
    Verified Answer
    Offline posted

    Hi,

    If you want to change the order in which the columns appear in the grid, I recommend that you use the InitializeLayout event of the grid.

    In this event, you can get the columns in the band and set the position of each one like so:

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

    e.Layout.Bands[0].Columns["column key 2"].Header.VisiblePosition = 1;

    It's important to set the VisiblePosition in order from 0 up. Because otherwise, the position of one column might alter the position of other columns.