VB.NET - How To Add,Edit, Remove Items From ListBox From Using Visual Basic .Net
In This VB.NET Tutorial We Will See How To Insert,Update,Delete Listbox Selected Item Using Visual Basic .NET Programming Language.
Project Source Code:
Public Class VBNET_ListBox
Private Sub BTN_ADD_Click(sender As Object, e As EventArgs) Handles BTN_ADD.Click
ListBox1.Items.Add(TextBox1.Text)
End Sub
Private Sub BTN_REMOVE_Click(sender As Object, e As EventArgs) Handles BTN_REMOVE.Click
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex())
End Sub
Private Sub BTN_UPDATE_Click(sender As Object, e As EventArgs) Handles BTN_UPDATE.Click
Dim index As Integer = ListBox1.SelectedIndex
ListBox1.Items.RemoveAt(index)
ListBox1.Items.Insert(index, TextBox1.Text)
End Sub
Private Sub ListBox1_Click(sender As Object, e As EventArgs) Handles ListBox1.Click
TextBox1.Text = ListBox1.SelectedItem.ToString()
End Sub
Private Sub BTN_ADD_ARRAY_Click(sender As Object, e As EventArgs) Handles BTN_ADD_ARRAY.Click
Dim items() As String = {"VB.NET",
"C#",
"C",
"C++",
"Java",
"PHP",
"JavaScript",
"Python",
"Ruby",
"IOS",
"Android",
"SQL",
"Swift"}
ListBox1.Items.AddRange(items)
End Sub
Private Sub BTN_RemoveAll_Click(sender As Object, e As EventArgs) Handles BTN_RemoveAll.Click
ListBox1.Items.Clear()
End Sub
End Class
///////////////OUTPUT: