foreach (GridRangeInfo ri in this.Selections.GetSelectedRows(true, false)) // throw exception in this.Selections.GetSelectedRows(true, false)
for (int i = ri.Top; i <= ri.Bottom; i++)
{
int rowIdx = i - 1;
...
}
Relevant stacktrace:
Object reference not set to an instance of an object.
Syncfusion.Grid.Windows
Data : System.Collections.ListDictionaryInternal
TargetSite : Void RemoveEmptyRanges()
HResult : -2147467261
at Syncfusion.Windows.Forms.Grid.GridRangeInfoList.RemoveEmptyRanges()
at Syncfusion.Windows.Forms.Grid.GridRangeInfoList.GetRowRanges(GridRangeInfoType filter)
at Syncfusion.Windows.Forms.Grid.GridModelSelections.GetSelectedRows(Boolean bRangeRowsOnly, Boolean considerCurrentCell)
Strange enough, when watching the variables in Visual Studio, I find the following:
this.Selections {Syncfusion.Windows.Forms.Grid.GridModelSelections}
- Count = 2
- Results View
- [0] = {30325}
- [1] = null
On and off the corresponding data grid becomes a big red cross with white background after this exception is thrown.
Can I know why it happens? Is it fixed in some newer version of Syncfusion? Or anything I need to pay attention when calling this method?
Thanks!
Query |
Response |
However I cannot always reproduce the issue. It sometimes happen when I sort the column or filter the data of data grid. We have a refresh timer to update the data grid from datasource when needed as well. |
We have created the sample as per your scenario (i.e create the custom control from GridControl) and updated the data source for particular time interval. Unfortunately we could not able to reproduce the issue. Please refer to the attached sample and let us know if we missed anything from your customization.
Sample link:
|
Can I know does Selections.Ranges return the same output as Selections.GetSelectedRows(true, false)? |
Yes. The Selections.Ranges and Selections.GetSelectedRows() methods will returns the same output.
Please refer to the below KB for further references,
|