I'm having trouble using the GetNextCell in a virtual grid when selecting rows. It seems, no matter how many columns I actually have, GetNextCell keeps returning columns which don't exist. Is there something wrong with the following code?
ArrayList rows = new ArrayList();
GridRangeInfoList selectedRows =
foreach (GridRangeInfo info in selectedRows )
if ( info.GetFirstCell(out top, out left) )
if ( !rows.Contains(top) )
} while( info.GetNextCell( ref top, ref left ));
The call to GetSelectedRows will return ranges of type GridRangeType.Row. The GetNextCell type works only with GridRangeType.Cell. What you should do is before the call to
if ( info.GetFirstCell ...
you should call
info.ExpandRange(1, 1, RowCount, ColCount);
This will convert the Row range into a Cell range that you can loop through.