Listbox strange behavior

This time, I narrowed down the problem. And this time, it is (more or less) my fault. I’ve created a prototype to add a new feature to an already existing window (with Listbox and TextArea) that leads to this trouble.

Xojo 2015r1 / El Capitan .6.

The conditions (Listbrow Properties before running the test code):
Columns: 2
Has Heading
Two strings provided for the Headings
Fixed size: 400,160 ( fills the Listbox actual width)
ScrollBarHorizontal: ON

The HTML (far below) is the data I decode and place the text between the bold tag into the Listbox headings, in a loop. To avoid OutOfBoundsException, I add a new Column in a line before Next.

The code works fine and is not needed here because it is not really involved in the trouble.

Once the Headings are populated, I still have the horizontal scrollbar, an still my two columns, but no clue that there are much more rows (in fact 8) available, because the horizontal scrollbar is nearly totally filled. Fortunately, this window is user resizeable, and when I had the curious idea to enlarge it, Iw as able to see the remainding 6 columns.

Once I had that clue, I tried:

LB_URLs.Refresh

But this was not the answer to the trouble.

After a coffee, I tried:

LB_URLs.ColumnWidths = "100,100,100,100,100,100,100,100"

And… all of a sudden, five and half columns in the Listbox were visible, the horizontal scrollbar shows there are rooms to move.

Conclusion:
The trouble appears because I have an horizontal scrollbar and the Listbox.ColumnWidths does not holds fixed values.

Is this a know bug ? If so, you know the work-around.

[code]

[/code]

The Xojo code below demonstrates the problem:

[code] Dim Col_Idx As Integer

For Col_Idx = 0 to 12
LB.Heading(Col_Idx) = “Foo”

LB.ColumnCount = LB_URLs.ColumnCount + 1

Next

LB_URLs.ColumnWidths = “100,100,100,100,100,100,100,100”[/code]

Quite simple code. BUT remember the properties of the LB Listbox.

Cover Links Title Size Date added DPI Pages Comics.org

I just checked the contents of LB.ColumnWidths and it holds… “400,160, , , , , , ,”.

To allow an Horizontal ScrollBar to be active (to activate), that property must holds pixel values (no M%, no *) and certainly not empty values.

For the record
There are 536 entries in Feedback that holds the word Listbox, Some of the status are open, some N/A, some Needs Review, some Not reproducible, etc…

With this amount of entries, and if this was in one of my software, I will totally rewrite the Listbox (and so it will comply to the new Framework).

So, I do not think a bug report will be useful.

It would need to know how wide the listbox is supposed to be.
But if you use * or a percentage, then the listbox displays the cells based on the current width… there is no horizointal scroll to be done… you should already be able to see it all.

I just found an alternate code:

 Dim Col_Idx As Integer
  
  For Col_Idx = 0 to 12
    LB.Heading(Col_Idx) = "Foo"
    
    LB.ColumnCount = LB_URLs.ColumnCount + 1
    LB.Column(Col_Idx + 1).widthExpression = "100"
  Next

Hi Jeff,

The Listbox width is 560 pixels (400 + 160). The user can enlarge the window ans so the Listbox too. The window current width is 600 pixels (so 20 pixels left and 20 pixels right margins).

You are right.

I wrote earlier that a new column added by code apparently does not have a width (read above).

The new code (in the previous entry), is far better than what I wrote earlier (who was correct, but only for that project / the decoded file): it set a fixed width in pixels to the new added Column.

BTW: I started this conversation with “This time…”. That is because I already fall into that trap, and I didn’t understand then why and how to workaround it. Now I know.

From the LR:

[b]Resizing Columns[/b] 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.
I use that mode, I love that mode.