At run time, if I add or remove a column, I do it by emptying the list and setting the column count.
Then I need to ensure that the columns have a width
It would be good to get the horizontal scrollbar to appear if the combined widths are too great
My problems at the moment:
After changing the columns and adding data, if I iterate through the columns and set a width of (say) 100 for narrow columns, then invalidate, nothing changes.
And even if the new combined widths are ‘too big’ to display, I never see the scrollbar
How best to set new column widths after changing the column count?
In API1, it seems automatic. (I added some columns in the IDE to a current project and set the widths to 100 for all 6 columns; the window width is > 500 pixels)
At run time I get the horizontal scrollBar (the property is Show if needed, of course).
I recall this is not the case if you use * or % in the ColumnWidths string.
No, I only do not searched that in the LR (by fear to not found it).
Also, depending on how you set the column widths, your column resizing experience will change (resizing a Column in the middle just resize that column OR have a side effect on other column(s)).
One have to check (what I wrote above) to really understand / sorry if I am not crystal clear.
Now, when I think of it, ‘*’ (and ‘%’ ?) means “variable column value”, so the ListBox width is always larger than all column widths…
I found it; here’s the first part, more paragraph to read (LR from 2015r1):
There are two “modes” for column resizing. There is no formal mode property. Rather, the “mode” is implicitly set according to whether every column width is specified as an absolute amount. If you specify all columns either in pixels or as a percentage, you will be using the second mode. If you use an asterisk or leave a column width blank, you will be using the first mode.
After reading the above, I came to the following solution (a 1 column example) to dynamically set the column width to the longest string:
dim w as Integer
if (UBound(App.myFiles) >= 0) then
w = 0
for i as Integer = 0 to UBound(App.myFiles)
if ((7 * len(App.myFiles(i))) > w) then
w = (7 * len(App.theFiles(i)))
ListBox1.ColumnWidths = str(w)