Class

ListColumn


Warning

This item was deprecated in version 2021r3. Please use DesktopListBoxColumn as a replacement.

Description

Used to refer to a particular column in a ListBox via its Column property.

Property descriptions


ListColumn.MaxWidthActual

MaxWidthActual As Integer

The maximum width of the column (points).

The following example sets the maximum width for the first three columns.

Me.Column(0).MaxWidthActual = 80
Me.Column(1).MaxWidthActual = 80
Me.Column(2).MaxWidthActual = 45

ListColumn.MaxWidthExpression

MaxWidthExpression As String

The maximum width of the column as a string expression that can include spaces and the percent sign.

To set column widths, you can use a mixture of pixels, percentages, and relative lengths. Column widths specified in pixels are guaranteed to have the specified width with the user resizes the ListBox or resizable columns. Column widths specified in percentages are guaranteed to have that percentage of the visible width of the ListBox. The column widths specified using the "*" divide up the remaining width proportionally. Using the "*" as the last column width, assigns all of the remaining width to the last column. Resizing a column will resize the value of the expression. If you resize the ListBox, both the percentage and relative lengths recompute their actual widths. There are two resizing "modes"; for more information, see Resizing Columns.

If there are three columns, the specification:

Listbox1.Column(0).MaxWidthExpression = "3*"
Listbox1.Column(1).MaxWidthExpression = "*"
Listbox1.Column(2).MaxWidthExpression = "10"

ListColumn.MinWidthActual

MinWidthActual As Integer

The minimum width of the column (points).

The following example sets the minimum widths of the first three columns.

Me.Column(0).MinWidthActual = 40
Me.Column(1).MinWidthActual = 30
Me.Column(2).MinWidthActual = 20

ListColumn.MinWidthExpression

MinWidthExpression As String

The minimum width of the column as a string expression that can include spaces and the percent sign.

The following line sets the minimum width of the first column in a ListBox to 15% of the total width of the ListBox.

Listbox1.Column(0).MinWidthExpression = "15%"

ListColumn.UserResizable

UserResizable As Boolean

True if the column is resizable; the default is False.

The following line in the Open event of a ListBox makes all the columns in the ListBox resizable:

Me.Column(-1).UserResizable = True

ListColumn.WidthActual

WidthActual As Integer

The width of the column in pixels.

This example sets the size of the first three columns in a ListBox.

Me.Column(0).WidthActual = 80
Me.Column(1).WidthActual = 80
Me.Column(2).WidthActual = 45

ListColumn.WidthExpression

WidthExpression As String

Column width as a string expression that can include the percent sign, a decimal point, or blanks.

Width can be specified as a value in pixels, a percentage, or a relative length. To obtain the absolute width of a column specified using percent or a relative length, call WidthActual. If you use * or %, the actual width will vary as the width of the ListBox changes.

To set column widths, you can use a mixture of pixels, percentages, and relative lengths. Column widths specified in pixels are guaranteed to have the specified width with the user resizes the ListBox or resizable columns. Column widths specified in percentages are guaranteed to have that percentage of the visible width of the ListBox. The column widths specified using the "*" divide up the remaining width proportionally. Using the "*" as the last column width, assigns all of the remaining width to the last column. Resizing a column will resize the value of the expression. If you resize the ListBox, both the percentage and relative lengths recompute their actual widths. There are two resizing "modes"; for more information, see Resizing Columns in the documentation for the ListBox control.

For example, if there are three columns, the specification:

Listbox1.Column(0).WidthExpression = "3*"
Listbox1.Column(1).WidthExpression = "*"
Listbox1.Column(2).WidthExpression = "10"

Notes

Use the UserResizable property to set the property, e.g.,

ListBox1.Column(1).UserResizable = False

To set column widths, you can use a mixture of pixels, percentages, and relative lengths. Column widths specified in pixels are guaranteed to have the specified width with the user resizes the ListBox or resizable columns. Column widths specified in percentages are guaranteed to have that percentage of the visible width of the ListBox. The column widths specified using the "*" divide up the remaining width proportionally. Using the "*" as the last column width, assigns all of the remaining width to the last column. Resizing a column will resize the value of the expression. If you resize the ListBox, both the percentage and relative lengths recompute their actual widths. There are two resizing "modes"; for more information, see Resizing Columns in the documentation for the ListBox control.

For example, if there are three columns, the specification:

Listbox1.Column(0).WidthExpression = "3*"
Listbox1.Column(1).WidthExpression = "*"
Listbox1.Column(2).WidthExpression = "10"

allocates a fixed amount of space to Column(2). There remaining width is divided up into four segments and allocates it between Columns 0 and 1 in the ratio of 3 to 1. This means that Column(0) gets the width of the ListBox minus 10 times 3/4, Column(1) gets the width of the ListBox minus 10) times 1/4, and Column(2) gets 10 pixels. As the ListBox changes in size (due to a window resize, for example) columns 0 and 1 will change to reflect that growth, while column 2 will not.

Header End caps are added for any additional unused space if headers are used. Header end caps do nothing when clicked.

If the string expression passed to WidthExpression, MinWidthExpression, or MaxWidthExpression cannot be evaluated to a width or a percentage width, an UnsupportedFormatException will occur. The Message property of this exception describes in English what went wrong.

Sample code

The following line in the Open event of a ListBox makes all the columns in the ListBox resizable:

Me.Column(-1).UserResizable = True

The following line sets the maximum width of the first column in a ListBox to 75% of the total width of the ListBox.

Listbox1.Column(0).MaxWidthExpression = "75%"

Compatibility

All project types on all supported operating systems.

See also

Object parent class; ListBox class.