Looping through columns in DisplayIndex order

3 posts, 1 answers
  1. Anne Lyon
    Anne Lyon avatar
    87 posts
    Member since:
    Jan 2010

    Posted 09 Mar 2015 Link to this post

    Hi,

    Is there a quick way of looping through all columns in a grid in DisplayIndex order?
    Something like:

    for (int i = 0; i < MyGrid.Columns.Count - 1; i++)
    {
    GridViewColumn myCol = TiltaksGrid.Columns.DisplayIndex[i];
    //process myCol...
    }

    Thanks!
  2. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 09 Mar 2015 Link to this post

    Hi,

    You can use a foreach instead. For example:

    foreach (GridViewDataColumn item in MyGrid.Columns.OfType<GridViewDataColumn>().OrderBy(x=>x.DisplayIndex))
    {
        ... 
    }

    Regards,
    Dimitrina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
  4. Anne Lyon
    Anne Lyon avatar
    87 posts
    Member since:
    Jan 2010

    Posted 09 Mar 2015 in reply to Dimitrina Link to this post

    Thank you, quick and useful response, as always!
Back to Top