From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Property (As String )
aDesktopListBoxColumn.WidthExpression = newStringValue
StringValue = aDesktopListBoxColumn.WidthExpression

New in 2021r3

Supported for all project types and targets.

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 DesktopListBox 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 DesktopListBox or resizable columns. Column widths specified in percentages are guaranteed to have that percentage of the visible width of the DesktopListBox. 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 DesktopListBox, 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 DesktopListBox control.

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

Listbox1.ColumnAtrributesAt(0).WidthExpression = "3*"
Listbox1.ColumnAttributesAt(1).WidthExpression = "*"
Listbox1.ColumnAttributesAt(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 DesktopListBox minus 10 times 3/4, column 1 gets the width of the DesktopListBox minus 10) times 1/4, and column 2 gets 10 pixels. As the DesktopListBox 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.