Question:

Visual Basic 2008 Listbox description

by  |  earlier

0 LIKES UnLike

Could provide example code for this Scenario:

I have a listbox with x amount of items, when I click on one I want a label to show a text description, when I click on a different item. The label's text changes to a different description for that item.

Thank you very much!

 Tags:

   Report

1 ANSWERS


  1. If you don't have to many items this will suit. if you have alot of items then use an string array to handle the description.

    Preload the ListBox Items Collection in the properties window with

    Car

    Bike

    Pizza

    Cut and paste into the code pane.

    Public Class Form1

        Public Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

            Select Case (ListBox1.SelectedIndex.ToString)

                Case 0

                    Label1.Text = "Ford"

                Case 1

                    Label1.Text = "AMF"

                Case 2

                    Label1.Text = "New york style"

            End Select

        End Sub

    End Class

    : )

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.