• Register now to get access to thousands of Tutorials, Leaked content, Hot NSFW and much more. Join us as we build and grow the community.

ListBox control

purplevenom

On-Chain Analyst
P Rep
0
0
0
Rep
0
P Vouches
0
0
0
Vouches
0
Posts
56
Likes
20
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 2 900 XP
A Listbox control allows user to select a single element or an item from a list. And it allows the programmer to add an item(s) at design time or at runtime.

This time,open visual basic and create a new application and save it as “listboxcontrol”. Then add a listbox from the toolbox, and it should look like as shown below.
listbox1.png


Then we can populate the listbox using the window properties.

Here’s the following steps

1. Select listbox control
2. Go to the properties window
3. Then select the items
4. And click the ellipses button
5. Then the string Collection Editor dialog box will open
6. And you can enter values one per line.
7. And click OK.

And it looks like as shown below:
listbox2.png


Another way to populate the listbox at design time and add items on it at runtime.to do this, double click the form and add the following code:
  1. ListBox1.

    Items

    .

    Add

    (

    "Apple"

    )
  2. ListBox1.

    Items

    .

    Add

    (

    "Banana"

    )
  3. ListBox1.

    Items

    .

    Add

    (

    "Grapes"

    )
  4. ListBox1.

    Items

    .

    Add

    (

    "Orange"

    )
  5. ListBox1.

    Items

    .

    Add

    (

    "Pineapple"

    )
  6. ListBox1.

    Items

    .

    Add

    (

    "Papaya"

    )

And here’s the output:
Example 1:
listbox3.png


Example 2:
listbox4.png


Book traversal links for ListBox control

  • ‹ ListBox Adding and Removing an Item in VB.NET
  • Up
  • Parameters/Arguments ›

 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

452,513

356,536

356,563

Top
Raidforums