This code will demonstrate how to add items and select them in a listbox
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim shirt, pants, shoes As String
Shirt = "shirt"
pants = "pants"
shoes = "shoes"
Me.lstTotalItems.Items.Add(shirt)
Me.lstTotalItems.Items.Add(pants)
Me.lstTotalItems.Items.Add(shoes)
Me.lstTotalItems.ScrollAlwaysVisible = True
End Sub
Private Sub btnItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnItem1.Click
lstTotalItems.SelectedItem = "shirt"
End Sub
Private Sub btnItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnItem2.Click
lstTotalItems.SelectedItem = "pants"
End Sub
Private Sub btnItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnItem3.Click
lstTotalItems.SelectedItem = "shoes"
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class
No comments:
Post a Comment