How to remove items from ListBox
I am having two list boxes namely emp1 and emp2. The first one is filled with 10000 entries whereas the other is empty. I want to move some of the entries from emp1 to emp2 for the employees which has left the company. To do so I have to remove the items from emp1 and then add them to emp2. Logic is proper but the problem is that I am unable to do. Can you help me how to code for removing an item from emp1 and then add them to emp2? How to remove items from ListBox?
Re: How to remove items from ListBox
The code should be something like this:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e _
As System.EventArgs) Handles Button1.Click
ListBox1.Items.RemoveAt(6)
'remove the item by specifying it's index number in the above code
End Sub
In short use Items.Remove or Items.RemoveAt() to remove the item from the listbox.
Re: How to remove items from ListBox
You can remove the item from emp1 by using the code:
Code:
emp1.RemoveItem (emp1.SelectedItem)
and then add the same item by using the code:
Code:
emp2.AddItem (emp1.SelectedItem)