In this article we will learn How to add items dynamically in ListBox windows forms using VB.Net.
In this blog we will see step by step How to add items dynamically in ListBox windows forms using VB.Net.
Step 1. We will add one ListBox, one textbox, one label and one button on windows form.
Step 2. In this step we will change the text of label and button. Need to open properties of label and button for change text just like given below screenshot.
Step 3. In this step we will double click on Add button for generate click event. After double click Form1.VB page will open. You can see in snap shot.
Step 4. Write this code on button click event in Form1.vb page for add items dynamically in ListBox windows forms using VB.Net.
Notes
ListBox1 Is the name of listbox
TextBox1 Is the name of textbox
item: An Object representing the item to add to the collection.
Add: Add an items in listbox
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ListBox1.Items.Add(TextBox1.Text)
TextBox1.Clear()
TextBox1.Focus()
End Sub
Output