ColumnWidths
The ColumnWidths property allows you to specify the widths of each column in a ComboBox or ListBox to force the columns to line up, even when using proportional fonts.
Usage |
lboListBox.ColumnWidths = cWidthsExpr cWidthsExpr = lboListBox.ColumnWidths |
Figure 1: ListBoxes without and with the ColumnWidths property set.
Specify ColumnWidths as a character string containing a comma-separated list of the widths of each column, in the current ScaleMode of the form, as in the example shown below. To calculate these widths, consider using TXTWIDTH() and FONTMETRIC() to get the values you need.
In early versions of VFP 6, ColumnWidths doesn't work if the form's ScaleMode has been set to 3–Foxels. All columns get set to the width of the first column, whether you set this in the Property Sheet or in code. We generally think that using foxels is a bad idea, as the geometry of the form depends on a font that may not even be used, so you shouldn't run into this one very often. The problem was fixed in one of the VFP 6 service packs. |
Example |
lstListBox.ColumnWidths = "40, 20, 60, 80" |
See Also |
ColumnCount, ComboBox, FontMetric(), ListBox, ScaleMode, TxtWidth() |