SpeakComputers.com online store
Electronics Software Computers Handhelds Laptops and Tablets Mobile Phones Digital Cameras Camcorders Games Music Books Sport Mens and Womens Watches Power Tools Household appliances

PRODUCTS

Software Downloads 2012 Software Mac Software Security Student Editions Windows 7 Office 2010

VB.NET ListBox Control.

The VB.NET System.Windows.Forms.ListBox control enables you to display a list of items from which the user can select one or multiple items from the list. The default is for the ListBox to list the items vertically however setting the multicolumn property to true the items are listed horizontally. The control is typically used to display data from a database. The items listed within the ListBox cannot be edited directly.

Namespace: System::Windows::Forms
System.Windows.Forms (in system.windows.forms.dll)

Creating an new VB.NET Windows forms ListBox.
Dim listbox As New ListBox

Assigning a new location for the VB.NET Windows Forms ListBox.
listbox.Location = New Point(0, 0)

Assigning a Selection Mode value to the VB.NET ListBox control.
listbox.SelectionMode = SelectionMode.MultiExtended

Adding a VB.NET ListBox control to the form.
Me.Controls.Add(listbox)

Adding items to the VB.NET ListBox control.
Dim s1 As String = "DELL"
Dim s2 As String = "HP"
Dim s3 As String = "SONY"
listbox.Items.AddRange(New String() {s1, s2, s3})

Creating a Selected Index Changed Event for the VB.NET ListBox control.
AddHandler listbox.SelectedIndexChanged, AddressOf listbox_selectedIndexChanged

Responding to the VB.NET ListBox Selected Index Changed event.
Private Sub listbox_selectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
MessageBox.Show(listbox.SelectedItem.ToString())
End Sub

VB.NET ListBox control Tutorial.
Home About Privacy Policy Resouces Search

Copy Right 2006 SpeakComputers.com - All Rights Reserved.