I am sorting the master/detail grid from the column header. I have a column which corresponds to the index of the row.
(int i = 0; i < m_northWindDataSet.Tables[nIndex].Rows.Count; i++)
m_northWindDataSet.Tables[nIndex].Rows[ i ].SetField(0, (i + 1).ToString());
//then I bind this table to grid.
When I sort a column in the grid the index column gets jumbled as per the sorting. Now i want that the index column to have values starting from 1 to n or n to 1 even after sorting i.e it resets its values as per sorting. The idea is to get say top 20 values after sorting.
Imported from legacy forums. Posted by Sudhir (had 1238 views)
Do you need this column for the user, or is it only internally in your application that you need it? If it is only internally, instead of using the an index column, you could use the sorted DataRows list, and retrieve the top 20 rows from it, and do what you need with the rows.
ReadOnlyDataRowList list = gridControl1.GetSortedDataRows( true );