DesktopListBoxColumn.MaxWidthExpression

From Xojo Documentation

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

Property (As String )
aDesktopListBoxColumn.MaxWidthExpression = newStringValue
or
StringValue = aDesktopListBoxColumn.MaxWidthExpression

New in 2021r3

Supported for all project types and targets.

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

Notes

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.

Sample Code

If there are three columns, the specification:

Listbox1.ColumnAttributesAt(0).MaxWidthExpression = "3*"
Listbox1.ColumnAttributesAt(1).MaxWidthExpression = "*"
Listbox1.ColumnAttributesAt(2).MaxWidthExpression = "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.