Articles in this section
Category / Section

How to trigger an event when the ComboBox DropDownList has null value or has no datasource bound to it?

1 min read

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

Showing empty ComboBox in GridControl

 

Sample links:

C# DropDownComboBox_CS

VB DropDownComboBox_VB

Conclusion

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