5
Contributors
5
Replies
7
Views
5 Years
Discussion Span
Last Post by ng5
-1

try this on your button click event:

While myListBox.SelectedItems.Count > 0
	myListBox.Items.Remove(myListBox.SelectedItems(0))
End While

Edited by renzlo: n/a

0

yes you can do it in this way

Try
            ListBox1.Items.Remove(ListBox1.SelectedItem)
        Catch ex As Exception
            MsgBox(Err.Description)
        End Try

Hope this will Solve your prob .

Regards

0

Try this....

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Me.ListBox1.SelectedIndex > -1 Then
            Me.ListBox1.Items.RemoveAt(Me.ListBox1.SelectedIndex)
        End If
    End Sub

Edited by kingsonprisonic: n/a

0

See this following code :

For i As Integer = 0 To ListBox1.SelectedIndices.Count - 1
   ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
Next

Or you use this too :

Do While (ListBox1.SelectedItems.Count > 0)
   ListBox1.Items.Remove(ListBox1.SelectedItem)
Loop
Votes + Comments
No Need of loop....
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.