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

GridVisibleColumnDescriptorCollection.get_TotalWidth - Object Reference not set

Hi, I have a grouping grid which occasionally raises an object reference not set exception and also occasioanly fails to draw the grid. I call a method that sets up the datasource and manually defines the columns to show based on parameters passed in. This a snapshot of the code: grid.SuspendLayout(); grid.DataSource = dataSource; grid.TableDescriptor.Columns.Clear(); grid.TableDescriptor.VisibleColumns.Clear(); grid.TableDescriptor.GroupedColumns.Clear(); grid.TableDescriptor.SortedColumns.Clear(); CreateDisplayColumns(); CreateGroupingColumns(); HideGroupingColumns(); AddSortByColumn(); grid.ResumeLayout(); CreateDisplayColumns does the following: It creates new GridColumnDescriptors and adds them to grid.TableDescriptor.Columns and grid.TableDescriptor.VisibleColumns for the columns the user wants to see. CreateGroupingColumns: Adds any required grouping cols to grid.TableDescriptor.GroupedColumns HideGroupingColumns: Simply sets colwidth to 0 for any grouping cols - this looks nicer AddSortByColumn: Adds a single sort by col to grid.TableDescriptor.SortedColumns if required. Is this the best approach for configuring the grid? Is there a better way in terms of performance? Would could be causing null reference exception. Thanks a lot Jason PS I''ve attached exception msg erortext_8085.zip

1 Reply

AD Administrator Syncfusion Team July 2, 2004 02:17 AM

FYI using grid.TableModel.BeginUpdate(BeginUpdateOptions.Invalidate) and grid.TableModel.EndUpdate(true) Seem to make a lot of difference. The exceptions haven;t appeared since and the grid display is a lot quicker.

Loader.
Live Chat Icon For mobile
Up arrow icon