Applies To: ComboBox | ListBox
You can display multiple columns in the control by setting the ColumnCount property. The values you specify for RowSource fill the control, by row, up to the number of columns specified by the ColumnCount property. For example, you can display values in multiple columns by setting RowSourceType to 1 (Value) and specifying the values, separated by commas, for each column and row for the RowSource property as shown in the following example:
myListBox.ColumnCount = 2
myListBox.RowSource = "Col1Row1,Col2Row1,Col1Row2,Col2Row2,Col2Row3"
In the example, no value is entered between the value in column 2, row 2 and the value in column 2, row 3 so no value displays in column 1, row 3.
To specify an alias for the table containing the columns, use the following syntax:
myListBox.RowSource = Alias.Col1Row1,Col2Row1,Col1Row2,Col2Row2,Col2Row3
Note: |
|---|
| When the ColumnCount property is set to 0 or 1, the control displays the first item or value only in a single column. Otherwise, the control displays each item or value in a column up to the number of columns specified by ColumnCount. You might need to set the ColumnWidths property to expand the width of the control so the items or values within display properly. |
For more information, see ColumnCount Property, How to: Create Multicolumn List Boxes, and Display Multiple Columns in a List Box Sample.
Because the default value for the Value property is numeric, if you want the Value property to reflect the character string of the selected item in a list box or combo box, set the Value property to an empty string (""). To enter an empty string in the Properties window, press the SPACEBAR key and then the BACKSPACE key. For more information, see Value Property and Properties Window.