I have Sfdatagrid bound to an observable collection. It works fine. I am trying to group by Country programmatically using the following code:
GroupColumnDescription myGrouping = new GroupColumnDescription();
myGrouping.ColumnName = "Country";
myGrid.GroupColumnDescriptions.Add(myGrouping);
But on the last line, the compiler throws error "SelectedCellInfo can't be null in Remove".
The following code for sorting the column works as expected, so I do not understand why grouping throws an error.
SortColumnDescription mySorting = new SortColumnDescription();
mySorting.ColumnName = "Country";
mySorting.SortDirection = ListSortDirection.Ascending;
myGrid.SortColumnDescriptions.Add(mySorting);
Grouping is enabled on the grid. I am using .NET Framework 4.8.
Any ideas?
Thank you. The file you sent runs fine. It appears the exception is thrown when my bound collection is empty and there is nothing to group.
In my app, my collection remains empty until info is received from a remote server. I can get grouping to work if I put in a suitable thread sleep before the grouping code is called. This feels cheap and not optimal, but it works.
My main problem now is that the order of my grouping is reversed from what I want (ascending vs descending). Is there a way to specify the Group sort order programmatically? I don't see this in the docs.
I don't want to show the Group Drop Area, which I recognize allows me to do it manually.
Thank you again!
Thank you.