Monday, February 14, 2011

Selecting items in a listbox

This code will show how to select items 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.Close()
End Sub ClassMe.lstTotalItems.Items.Add(shirt)Me.lstTotalItems.Items.Add(pants)Me.lstTotalItems.Items.Add(shoes)Me.lstTotalItems.ScrollAlwaysVisible = TrueEnd Sub
lstTotalItems.SelectedItem = Private Sub btnItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnItem1.Click"shirt"End Sub
lstTotalItems.SelectedItem = Private Sub btnItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnItem2.Click"pants"End Sub
lstTotalItems.SelectedItem = Private Sub btnItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnItem3.Click"shoes"End Sub 



EndPrivate Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

No comments:

Post a Comment