A list of all the DataRows contained within the grid can be retrieved using the grid's collection of DataRows; however, the list returned will contain the DataRows in the order that they are found in the data source. If you want to retrieve the DataRows in the order that they are sorted in the grid, then you will need to use the grid's GetSortedDataRows method.
The GetSortedDataRows method also allows you to retrieve the DataRows recursively depending on the value of its recursive parameter. If the grid does not contain any groups, then setting the recursive parameter to true or false will have the same result: all the DataRows will be retrieved. If the grid contains groups, then setting the recursive parameter to false will result in no DataRows being returned since the DataRows are contained within the groups. Setting the recursive parameter to true (in the case where the grid contains groups) will result in all the DataRows being returned.
It is also possible to retrieve the DataRows of a specific group using the group's GetSortedDataRows method.
The following example demonstrates how to retrieve a list of all the DataRows in the grid in the order that they are sorted. Because we are setting the recursive parameter of the GetSortedDataRows method to true, all DataRows, event those contained within groups, will be retrieved.
VB.NET | Copy Code |
---|---|
Dim rows As Xceed.Grid.Collections.ReadOnlyDataRowList = GridControl1.GetSortedDataRows( True ) For Each row in rows |
C# | Copy Code |
---|---|
|