The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I have a virtual grid where I''m using QueryCellInfo for displaying data and SaveCellInfo for updating certain cells.
I''m getting the following unhandled exception often. I''m still trying to find a sequence of steps that causes it, but it generally seems to happen when clicking on a cell (it must at that point be in some state).
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Syncfusion.Windows.Forms.Grid.GridControlBase.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at Syncfusion.Windows.Forms.ScrollControl.WndProc(Message& msg)
at Syncfusion.Windows.Forms.Grid.GridControlBase.WndProc(Message& msg)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Is this a known problem? I''m using 3.2.1.0
Thanks
STstanleyj Syncfusion Team December 20, 2005 05:00 PM UTC
Hi Ken,
In your QueryCellInfo and SaveCellInfo handler have you checked for e.RowIndex > 0, if not please try.
void GridQueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if (e.RowIndex > 0 && e.ColIndex > 0)
{
//
//
//
}
}
Regards,
Stanley
KLKen LawDecember 20, 2005 08:45 PM UTC
Actually, I''m using QueryCellInfo to set column header text like this:
if (e.RowIndex == 0)
e.Style.Text = this.GetColumnHeaderValue(e.ColIndex);
I''ve done this with other grids with no problems.
Here is the code from my SaveCellInfo event:
try
{
//Move the changes back to the external data object. Checking for >1 so PartID cannot be affected
if( e.RowIndex > 0 && e.ColIndex > 1 && e.RowIndex <= this.m_oECPartCycle.ECKnownPartList.Count) //col index >2 because SensorID and Freq columns should be read-only
{
// Note: calling with 1-based row and column index values
this.SetCellValue(e.RowIndex, e.ColIndex, e.Style.CellValue.ToString());
}
}
catch{}
e.Handled = true;
Note that I do check for e.RowIndex > 0 here.
STstanleyj Syncfusion Team December 21, 2005 06:43 AM UTC
Hi Ken,
I suggested those checks because QueryCellInfo handler queries from (-1,-1). The reason to query with -1 is to denote -1 for colstyles and rowstyles. If you could provide more detail on that then we may try suggesting something. You can also upload the sample so that the issue can be seen here.
Thanks,
Stanley
KLKen LawDecember 31, 2005 07:50 PM UTC
I seem to have eliminated the problem by setting some other properties. For example, I''ve made the cells that will not receive user input static and set some other properties.