Articles in this section
Category / Section

How to resolve null reference exception in WinForms GridGrouping?

3 mins read

Resolve null reference exception

While changing the DataSource in the ComboBox cell in WinForms Grid Grouping, a null reference exception is raised. This is because the database is updated and then refreshed after you pick a value from a ComboBox cell by using the RecordValueChanged event. The newly edited value is not committed while the database updates. So, when you try to click on the next row, the RecordValueChanged event refreshes the database before the ComboBox commits the new value into the underlying database.

 Show the null reference exception in WinForms Grid Grouping

Figure 1: Null reference exception

This can be solved by calling the EndEdit() in the TableControlCurrentCellCloseDropDown event. Refer to the following code example.

C#

void gridGroupingControl1_TableControlCurrentCellCloseDropDown(object sender, GridTableControlPopupClosedEventArgs e)
{
   if(e.Inner.PopupCloseType == Syncfusion.Windows.Forms.PopupCloseType.Done)
   {
      // Commits value in the ComboBox manually.
      e.TableControl.CurrentCell.EndEdit();
   }
}

VB

Private Sub gridGroupingControl1_TableControlCurrentCellCloseDropDown(ByVal sender As Object, ByVal e As GridTableControlPopupClosedEventArgs)
   If e.Inner.PopupCloseType = Syncfusion.Windows.Forms.PopupCloseType.Done Then
      'Commits value in the ComboBox manually.
      e.TableControl.CurrentCell.EndEdit()
   End If
End Sub

 


Conclusion

I hope you enjoyed learning how to resolve null reference exceptions in WinForms GridGrouping.

You can refer to WinForms GridGrouping feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms GridGrouping example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied