i am working on windows applications. In my applicaion One combobox, one button(neamed as delete) is there.
I would like to delete the selected combobox item .So I wrote code to delete a selected item under delete button click. In this i want to check if the combobox selected item is null, after clicking on the button delete it displays some error message like, "There is no item to delete. You selected nothing."
i wrote this code
Expand|Select|Wrap|Line Numbers
- If (ComboBox1.Items.Count = 0) Then
- MessageBox.Show("There are no items in the combobox")
- Else
- Dim str As String
- str = ComboBox1.SelectedItem
- If (str.Equals(Nothing)) Then
- MessageBox.Show(" No item is selceted", "", MessageBoxButtons.OK, MessageBoxIcon.Error)
- Else
- count = count - 1
- ComboBox1.Items.Remove(str21)
- End If
- End If