-
Prospect
cegonsoft private limited | Adding items to the list box in VB.NET
Adding items to the list box
A list box can be populated either at design time using the Visual Studio IDE or at runtime using code. To add items to the list box using the Visual Studio IDE, select the list box control in the designer and in the properties window click the Items property. It will show you an interface where you can enter the list of items to be added to the list box.
Alternatively, you can write code to add items to the list box. An item can be added to the list box using the Add() method from the Items collection of the ListBox object. Assume that we have made a list box to store the names of Fruits and that we have set the Name property of the list box to 'lbxFruits'. The following code can be used to add items to the list box.
lbxFruits.Items.Add("Banana")
lbxFruits.Items.Add("Mango")
Or if you want to add a series of items, you can use the AddRange() method of the Items collection
lbxFruits.Items.AddRange(New String() {
"Banana",
"Mango",
"Apple",
"Grapes",
"Lichie"
})
Visit: Cegonsoft
-
Prospect
Example for Adding items neatly
Dim fmtstr As String = "{0,-10}{1,12}{2,14}"
With lstservices.Items
.Clear()
.Add(String.Format(fmtstr, "Room Rentals ", "Half-Day ", "Full-Day"))
.Add(String.Format(fmtstr, "1. Standard Rooming ", "$32.00 ", "$65.00"))
.Add(String.Format(fmtstr, "2. Deluxe Rooming ", "$72.00 ", "$144.00"))
End With
cegonsoft
-
Prospect
hi hello guys how are tyou...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules