Returns or sets a value that determines whether a ListBox control scrolls vertically or horizontally and how the items in the columns are displayed. If it scrolls horizontally, the Columns property determines how many columns are displayed.
object.Columns [= number]
The parts of the Columns property syntax are described in the following table.
Part | Description |
---|---|
object | An object expression that evaluates to an object. |
number | An integer that specifies how a control scrolls and how items are arranged in columns, as described in Settings. |
The settings for number are described in the following table.
Setting | Description |
---|---|
0 | (Default) Items are arranged in a single column and the ListBox scrolls vertically. |
1 to n | Items are arranged in snaking columns, filling the first column, then the second column, and so on. The ListBox scrolls horizontally and displays the specified number of columns. |
For horizontal-scrolling ListBox controls, the column width is equal to the width of the ListBox divided by the number of columns.
This property can not be set to 0 or changed from 0 at run time — that is, you cannot change a multiple-column ListBox to a single-column ListBox or a single-column ListBox to a multiple-column ListBox at run time. However, you can change the number of columns in a multiple-column ListBox at run time.