How to Detect When VisualItemCollection is Modified in MultiSelectionCombobox in Windows Forms MultiSelectionComboBox

28 Apr 2021 / 1 minute to read

This page explains How to Detect when VisualItemCollection is Modified in MultiSelectionComboBox and more details.

How to Detect when VisualItemCollection is Modified in MultiSelectionComboBox

The following code explains you on how to detect the VisualItemCollection modification using VisualItemCollectionChanged event. This event is triggered once VisualItem collection is modified in MultiSelectionComboBox.

private void MultiSelectionComboBox1_VisualItemsCollectionChanged(object sender, VisualItemCollectionChangedArgs e)
{

// To define collection modification
    if (e.Action == Actions.Added)
    {
        string text = e.VisualItems[0].ToString();
    }
}
Private Sub MultiSelectionComboBox1_VisualItemsCollectionChanged(sender As Object, e As VisualItemCollectionChangedArgs)

' To define collection modification
If e.Action = Actions.Added Then
Dim text As String = e.VisualItems(0).ToString()
End If
End Sub