Friday, November 7, 2008

Selecting all Items in a ListBox in VB.NET

It seems to me like there should be a method that would select or deselect all items in a listbox, but there is not. Here is a simple sub to accomplish this task:


Public Sub SelectAllListBoxItems(ByVal lv As ListBox, ByVal selected As Boolean)

For i As Integer = 0 To lv.Items.Count - 1

ListBoxValidations.SetSelected(i, selected)

Next

End Sub

No comments: