Home Forums WinForms controls Xceed Grid for WinForms Column order for collections

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #13401 |

    Hi. I am binding a typesafe collection to a grid. I am not creating any columns at design time – the columns are being created dynamically when the DataSource property is set. How does the grid decide the order in which these columns are displayed, and how can I set my own preferred order?

    Many thanks

    kh

    Imported from legacy forums. Posted by kh (had 3306 views)

    User (Old forums)
    Member
    Post count: 23064

    To set the <b>visible</b> order of the columns, you can use the <b>VisibleIndex</b> property of the Column objects. Like this:<code>myGrid.Columns[“Column1”].VisibleIndex = 0;
    myGrid.Columns[“Column2”].VisibleIndex = 1;
    myGrid.Columns[“Column3”].VisibleIndex = 2;</code>

    Imported from legacy forums. Posted by Tommy (had 171 views)

    User (Old forums)
    Member
    Post count: 23064

    cheers tommy. i kind of hoped i could do it without hardcoding the grid to a particular bound object. i.e. the object itself determines the column order. i can think of many ways to hack this, but hoped for an elegant (e.g. attribute based) solution.

    kh

    Imported from legacy forums. Posted by kh (had 331 views)

    User (Old forums)
    Member
    Post count: 23064

    But the object itself already DOES define the column order….. The columns are displayed in the same order as they appear in your datatable (Hopefully 🙂 ).

    Imported from legacy forums. Posted by Kai (had 255 views)

    User (Old forums)
    Member
    Post count: 23064

    Kai. Thanks, but I’m not binding a DataTable. I’m binding a typed collection and the grid does not appear to use e.g. the order in which child object properties are defined. This is possibly not an Xceed grid issue but a more general databinding issue.

    I’m not losing any sleep over this one, just wondered if anyone knew how this works

    Thanks

    kh

    Imported from legacy forums. Posted by kh (had 4607 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.