This is a migrated thread and some comments may be shown as answers.

Looping through columns in DisplayIndex order

2 Answers 688 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anne Lyon
Top achievements
Rank 1
Anne Lyon asked on 09 Mar 2015, 09:06 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 09 Mar 2015, 12:33 PM
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.

 
0
Anne Lyon
Top achievements
Rank 1
answered on 09 Mar 2015, 12:45 PM
Thank you, quick and useful response, as always!
Tags
GridView
Asked by
Anne Lyon
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Anne Lyon
Top achievements
Rank 1
Share this question
or