JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Making List Boxes Scroll Horizontally (Multicolumn List Boxes)

It's a pity that there's so little vertical space for the list box in your new program's layout—the user can view only 4 of the more than 40 items in the list box at once. Can't you make a list box work horizontally instead of vertically?

You sure can, if you set the MultiColumn property of a list box to True, giving it multiple columns. Here's how that looks in code, where I'm creating a multicolumn list box:

Dim ListBox1 As ListBox

Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    ListBox1 = New ListBox()
    ListBox1.Size = New System.Drawing.Size(270, 100)
    ListBox1.Location = New System.Drawing.Point(10, 40)
    ListBox1.MultiColumn = True

    Dim intLoopIndex As Integer
    For intLoopIndex = 1 To 20
        ListBox1.Items.Add("Item " & intLoopIndex.ToString())
    Next intLoopIndex
End Sub

What does this list box look like? See the next topic, where I'm also making this list box support multiple selections.

Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor