Senin, 09 Februari 2009

MultiSelect ListBoxes


MultiSelect ListBoxes

Most beginner Visual Basic programmers are familiar with one of my favorite controls--the ListBox.

The ListBox permits the programmer to load it up with a number of items, allow the user to make a selection, and then proceed accordingly. ListBoxes are ideal controls for presenting a list of choices to the user---whether a few items or a large number, ListBoxes are an ideal control to use.

The AddItem Method




Most beginner programmers believe that the user's selection in a ListBox is limited to a single item. After all, when the user makes a selection in a ListBox, if they click on another item, the currently selected item is 'unselected'. Let's create a form with two ListBoxes and two command buttons, and use this code in the Load Event Procedure of the form to load into the first ListBox the original 13 colonies of the United States…

Private Sub Form_Load()

With List1

.AddItem "Connecticut"

.AddItem "Delaware"

.AddItem "Georgia"

.AddItem "Maryland"

.AddItem "Massachusetts"

.AddItem "New Hampshire"

.AddItem "New Jersey"

.AddItem "New York"

.AddItem "North Carolina"

.AddItem "Pennsylvania"

.AddItem "Rhode Island"

.AddItem "South Carolina"

.AddItem "Virginia"

End With

End Sub

AddItem, for those of you unfamiliar with it, is a method that will add an item to a ListBox (You can also add items via the List Property of the ListBox at design time, but using the method is a lot more dynamic…)

When we run the program and our form appears, this is what we'll see…



source: http://www.vbexplorer.com/VBExplorer/VBExplorer.asp


------------------------------------------


Related:


single-record
Trik Cara Melacak IP
Trik Choose Phone
Trik woodwork-stores
Trik woodwork supplies
Trik wood work tool
Using radio button vb2008
Valentineday
vb2008 with control
vb2008 with control properties
vb2008 with oriented programming
VB.NET Solution files
VB.NET Code myclass