We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Exception in virtual grid

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

4 Replies

ST stanleyj 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


KL Ken Law December 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.


ST stanleyj 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


KL Ken Law December 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.

Loader.
Live Chat Icon For mobile
Up arrow icon