Adding items into ListBox control in VB.NET

This article shows you how to add items to a ListBox control.
  • 10011

Ok, adding items to a listbox control is easy. You use Add method of the control. The following code shows you how to do so.

Drag a ListBox control on a form and use the following code to add items to the control.

Adding1.gif

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim str As String = "First item"
Dim i As Integer = 23
Dim flt As Single = 34.98F
listBox1.Items.Add(str)
listBox1.Items.Add(i.ToString())
listBox1.Items.Add(flt.ToString())
listBox1.Items.Add("Last Item in the List Box")
End Sub 'Form1_Load

Categories

More Articles

© 2013 dotNetheaven. All rights reserved.