How to trigger an event when the ComboBox DropDownList has null value or has no datasource bound to it?
If the ComboBox in WinForms GridControl is neither bound to any datasource not has list items, it can be notified to the user by clicking on it. The notification message that the user wants to display can be given through TableControlCurrentCellShowingDropDown event.
Code Snippet
C#
// form() // Trigger the required event. gridControl1.CurrentCellShowingDropDown += gridControl1_CurrentCellShowingDropDown; void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e) { GridComboBoxCellRenderer rend = gridControl1.CurrentCell.Renderer as GridComboBoxCellRenderer; ListBox list = rend.ListBoxPart; if(list.Items.Count==0) { MessageBox.Show("ComboBox is Empty"); } }
VB
' form() ' Trigger the required event. Private gridControl1.CurrentCellShowingDropDown += AddressOf gridControl1_CurrentCellShowingDropDown Private Sub gridControl1_CurrentCellShowingDropDown(ByVal sender As Object, ByVal e As GridCurrentCellShowingDropDownEventArgs) Dim rend As GridComboBoxCellRenderer = TryCast(gridControl1.CurrentCell.Renderer, GridComboBoxCellRenderer) Dim list As ListBox = rend.ListBoxPart If list.Items.Count=0 Then MessageBox.Show("ComboBox is Empty") End If End Sub
Screenshot
Sample links:
I hope you enjoyed learning about how to implement an excel accounting format in the syncfusion WinForms GridControl.
You can refer to our WinForms GridControl’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridControl documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms 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 WinForms GridControl and other WinForms components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!