ListBox ColumnWidths Bug?

Looking for verification that this may be a small ListBox bug:

lbTable.ColumnWidths = “120,65” //Does not work, need to add space before second size like so:
lbTable.ColumnWidths = “120, 65” //works

(tried to open FeedBack to search, but ‘resources busy’)

Column 0 will be 120 px wide
Column 1 will be 65 px wide
Column 2 will use the rest of the listbox

I get the same result with space and without space.

I should have clarified, in logic I need to add a space (as opposed the the parameters during design on the right).

So:

If lbTable.ColumnWidths = “120, 65” Then
lbTable.ColumnWidths = “185, 0”
Else
lbTable.ColumnWidths = “120, 65”
End If

Will work, but if you take out the space before the second size, it will not work.

You can do

lbTable.ColumnWidths = "120,65" // or lbTable.ColumnWidths = "120, 65"
and both will work and show the same result. But of course querying the property can only return one kind of string and this is the one with the space. Not a bug for me.

Okay, that’s confusing to me, why is querying a property different than writing a property?

It’s not different. You can write and query the same way as long as you use a space after the comma. Writing the property without space after the comma is kind of a fault-tolerant version of writing with a space after the comma.

I see, so XoJo in the background is adding a space? Because in C “120,65” as a string is not the same as “120, 65”. (string meaning ASCII chars followed by ‘\0’ …of course.)

The ColumnWidth property is not a string internally. When writing to ColumnWidth the value is split by the comma, and then it sets the ListColumn.WidthExpression for each column. When red it reads all ListColumn.WidthExpression and joins them with ", ".

By the way you can also set ColumnWidth to “120, 65” and it will work.

[quote=177298:@Eli Ott]The ColumnWidth property is not a string internally. When writing to ColumnWidth the value is split by the comma, and then it sets the ListColumn.WidthExpression for each column. When red it reads all ListColumn.WidthExpression and joins them with ", ".

By the way you can also set ColumnWidth to “120, 65” and it will work.[/quote]

I precisely worked with ColumnWidths a few minutes ago, trying to position a label based on columns widths. That is when I found that ColumnWidths was still retaining the * for variablewidth columns.

I thought about using the g.Width value available in CellBackGroundPaint to get the actual value, but is there another way ?

Use ListColumn.ActualWidth.

I see, thanks.

Thank you Eli.

This didn’t show up properly. What I meant is:

lbx.ColumnWidth = "120,             65"

[quote=177308:@Eli Ott]This didn’t show up properly. What I meant is:

lbx.ColumnWidth = "120,             65"

gotcha, thanks.

I use constant to colomnwidth and Xojo 2016r3 doesn’t allow to enter constant ( #MyListBoxColWidth ) , but it woks with source code with constant (if we entered them in a previous version of xojo).

please file a bug report about this