Private Sub ColorGridGroups(ByVal grid As GridControl) Dim Toggle As Boolean = False For Each myGroup As Group In grid.Groups Toggle = (Toggle = False) If Toggle Then myGroup.BackColor = Color.Beige End If Next End Sub
The problem is this: The groups are built dynamically and are getting placed into the Groups collection in the order of creation – but VISUALLY they are sorted (ascending) so the above loop does not produce the desired result which would be “Alternating group colors.”
Is there anyway to loop the Groups collection in a sorted manner? Or alternately is there a method like, GetSortedGroups that I’m not seeing?
I’m looking for a convenient method, not the grunt method which would be capturing the Title of the group into an arraylist along with their indexes, sorting the arraylist and then looping through that sort.
Imported from legacy forums. Posted by Curtis (had 2344 views)
Try this (untested code):<pre>Dim toggle As Boolean = False Dim row As Xceed.Grid.DataRow Dim group As Xceed.Grid.GroupBase = Nothing For Each row in grid.GetSortedDataRows(True) Do If row.ParentGroup <> group Then group = row.ParentGroup toggle = Not toggle If toggle Then group.BackColor = Color.Beige End If End If Next</pre>
Imported from legacy forums. Posted by Tommy (had 349 views)