The UltraGrid GroupBy functionality is impressive! The problem is that it messes up later processing that retrieves data from cells in the grid which produces "object reference not set" and "index was out of range" exceptions. This is the code. for (int i = 0; i < uGrid.Rows.Count; i++){ Boolean value = (Boolean)uGrid.Rows[i].Cells[0].Value; if (value == true) { string action= (string)uGrid.Rows[i].Cells[2].Value; string item = (string)uGrid.Rows[i].Cells[3].Value; if (action == ADDED) { selectedItemList.Add(item); } }}
If the checkbox in Cell[0] is checked (i.e. true) then it processes information in Cell[2] and Cell[3]. This works properly when the grid first displays. This doesn't happen simply by moving one column laterally. But when I change things around with GroupBy the errors occur.
Somehow the code needs to keep track of the grid changes after GroupBy changes. Any ideas on what grid events and properties are needed? I've tried a bunch of things but haven't figured it out yet.
Thanks in advance...
I had figured out how to look for IsGroupBy rows and skip those, but it relied on somewhat complicated if statements. I modified the code to use this method instead and now the code is simpler. Many thanks for the tip!
Once the grid is grouped, the root-level rows collection becomes a collection of GroupByRows, which have no cells. So that's why this code doesn't work.
There's an easy solution, though, and it doesn't require you to know whether the grid is grouped or not.
foreach (UltraGridRow row in this.ultraGrid1.Rows.GetAllNonGroupByRows()){}