To explain better how to remove multiple selected items in ListBox I will use the form structure from the previous post "How to remove selected item in Listbox" with little changes. Plus I will add an option for multi selection in Listbox and additional button for multi deletion.
Add items in Listbox
ListBox1.Items.Add("some text")
ListBox1.Items.Add("some text 1")
ListBox1.Items.Add("some text 2")
ListBox1.Items.Add("some text 3")
ListBox1.Items.Add("some text 4")
To add multi selection in Listbox I added a code in Form1_Load event
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ListBox1.SelectionMode = SelectionMode.MultiSimple
End Sub
Remove multiple selected items in Listbox code
For i As Integer = ListBox1.SelectedIndices.Count - 1 To 0 Step -1
ListBox1.Items.RemoveAt(ListBox1.SelectedIndices.Item(i))
Next
Thursday, October 26, 2017
How to remove multiple selected items in ListBox
Tags
# ListBox
About Gabriel
Templatesyard is a blogger resources site is a provider of high quality blogger template with premium looking layout and robust design. The main mission of templatesyard is to provide the best quality blogger templates which are professionally designed and perfectlly seo optimized to deliver best result for your blog.
ListBox
Labels:
ListBox
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment