[Help]Removing item from listbox [solved]

Posts 1–10 of 10 · Page 1 of 1
[Help]Removing item from listbox [solved]
i want to delete an item out of the list box when i click a button on that selected item so this is what i did but didnt work ..

Code:
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ListBox1.Items.Remove(ListBox1.SelectedItem)
    End Sub
Quote Originally Posted by master131 View Post
Works for me.
damn idk then like i put it in but the button can read it ur sumthen bcz nothing happens when clicked
are you sure it selected? when you press the button?
yea im sure bcz i got it where when i click it the url plays then i click again on it an its lighted up blue then i click button to clear it but it dont do nothing i dont get no errors either
@topblast
Use break points, see if it even goes to the sub

Try this code:
Code:
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        if not listbox1.selecteditem = "" then
ListBox1.Items.Remove(ListBox1.SelectedItem)
Else
Msgbox("no selected item!")
End if
End Sub
Dim index as Integer = listbox1.SelectedIndex
if index <> -1 then
listbox1.items.removeat(index)
end if
listBox1.Items.Remove(listBox1.SelectedValue);

i think i cant remember havent used list box in ages :P
already solved thanks tho / close @Jason
Thread marked solved. Bleh this section is in need of a firm scrubbing.
Posts 1–10 of 10 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us