Listbox Addrow problem

I’m seeing a strange problem with ListBox.AddRow (on Windows 10, Xojo 2014r4) and I’d like to know if anyone else is seeing it or has a solution.

My app retrieves some data from a web API and uses the data to build an 8 element string array. It then does a ListBox1.AddRow(theArray) to populate the data into an 8-column listbox. Instead of the entire row coming visible, only the first three columns show data. The data is there in the other cells and will get displayed if I click on a header or select the row. If the data returned from the API has multiple sets of data, each set will populate the array in turn and be added to the listbox. In this case, all of the rows are completely displayed except for the last row which, again, only displays the first three columns.

I have tried putting a ListBox1.Invalidate after the row(s) have been added but that does not seem to help. Other than putting the data into the listbox, I am doing no Cell text processing. I’ve tried Adding a blank row and populating the cells individually but that doesn’t seem to help either. I’ve cleared the caches, uninstalled and reinstalled 2018r4 but the problem remains.

I’ve tried to create a test program to show the problem but each time I do the issue doesn’t manifest.

The project works fine if built under 2018r3. I’m at the end of the few wits I have left.

How is the data being fetched?

Assuming you meant 2018r4 and not 2014r4" as posted, the fact that it works fine under 2018r3 would seem to indicate a Xojo bug introduced in the last release. Of course, if you can’t submit a sample project any feedback report will be closed as “not reproducible” :frowning:

Do you have any code inside the CellBackgroundPaint, CellTextPaint or DisclosureWidgetPaint events?
Is the ListBox sitting inside any other controls, or is it directly on the window?
What scale factor is your desktop?

The data is being fetched through a Xojo.Net.HTTPSocket and processed into the array in the PageReceived event handler before being sent to the listbox. Examination of the populated array immediately before the AddRow call shows that the data is there and correct, so I don’t see how that could be the problem.

[quote=419861:@]Do you have any code inside the CellBackgroundPaint, CellTextPaint or DisclosureWidgetPaint events?
Is the ListBox sitting inside any other controls, or is it directly on the window?
What scale factor is your desktop?[/quote]
There is no code in any of the cell-specific events. That was the first thing I removed in my debugging attempts. The listbox is directly on the window. The only other controls on the window are a pushbutton, a couple of labels, and a textfield, none of which encroach on the listbox. The scalefactor of the window is 1 (I don’t think I’ve ever used this particular item).

Oops! Yeah, that was a typo. I’m using 2018r4 when I see the problem, not 2014r4.

If you change the addrow to insert static data does it still break? i.e.

s = Array ("1", "2", "3", "4", "5", "6", "7", "8") listbox1.AddRow(s)

[quote=419911:@]s = Array (“1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”)
listbox1.AddRow(s)[/quote]
Yes. Only the 1, 2, and 3 show up.

Just for fun, I added a second listbox and added an AddRow call pointing to the second listbox immediately before the call to the original llistbox. This new listbox has no code in any event handler and, except for the column count, is totally vanilla.

Both listboxes show only the first three columns.

I need to do more detective work, I guess.

Oh good, this means it’s not a sneaky Xojo.Net.HTTPSocket bug. There were some weird behaviors on Windows at one point, which is why I was curious if the socket could possibly be the issue.

I like to narrow things like that down as quickly as I can :wink:

PM sent to you Dale

Htpp post?

Very odd. This works for me in 2018R4:

Dim num() As String = Array(“1”,“2”,“3”,“4”,“5”,“6”,“7”,“8”)
ListBox1.AddRow(num)

so does this:

listbox1.AddRow(“1”,“2”,“3”,“4”,“5”,“6”,“7”,“8”)

Maybe just loop through your array with a msgbox, examining the contents?

No, use the debugger to scan (read) what the array contents is.

Back to :

Dim num() As String = Array("1","2","3","4","5","6","7","8") ListBox1.AddRow(num)

What happens if you use:

[code] Dim num() As String = Array(“1”,“2”,“3”,“4”,“5”,“6”,“7”,“8”)
LB.AddRow(num)

LB.ColumnCount = UBound(num)+1[/code]

Random thoughts:

The fact that your own test programs do not exhibit the problem may be a useful clue - look for differences between that case and your app that has the bug.

I assume that the problem only manifests when using AddRow and not if you write to the cells individually, right?

You said you tried listbox.invalidate - have you tried listbox.refresh?

[quote=420010:@Emile Schwarz]No, use the debugger to scan (read) what the array contents is.

Back to :

Dim num() As String = Array("1","2","3","4","5","6","7","8") ListBox1.AddRow(num)

What happens if you use:

[code] Dim num() As String = Array(“1”,“2”,“3”,“4”,“5”,“6”,“7”,“8”)
LB.AddRow(num)

LB.ColumnCount = UBound(num)+1[/code][/quote]
Checking the array in the debugger before and after the AddRow shows in both cases that the array contains the correct data. BTW, it’s a String array so there’s no on-the-fly conversions.

[quote=420026:@Julia Truchsess]Random thoughts:

The fact that your own test programs do not exhibit the problem may be a useful clue - look for differences between that case and your app that has the bug.

I assume that the problem only manifests when using AddRow and not if you write to the cells individually, right?

You said you tried listbox.invalidate - have you tried listbox.refresh?[/quote]
Yes, I tried Listbox1.Refresh also and had the same results. As for writing to the cells individually, that caused only the first TWO cell to be displayed.

What is really confusing me about this is the fact that if I click on the listbox’s Header, the cells in the listbox show all of the data in the cells. This tells me that the cells actually have the data in them but for some reason aren’t displaying it.

My last statement in my post had me thinking. If it is just a display problem, maybe I should simply set the ListBox’s Selected row to LastIndex and then remove the value. So I put in the code immediately after the AddRow

Listbox1.Selected(Listbox1.LastIndex) = True Listbox1.Selected(Listbox1.LastIndex) = False
and that seems to work. It’s about as ugly a solution workaround as there is but at least it works.

My thanks to everyone who gave suggestions and brain cells on this.

What’s bugging me is that I have a vague recollection of encountering this myself at some time in the past, but my fading memory can’t retrieve it, sorry :frowning: I’ll keep trying.

Can you provide the project to someone to look at? Unfortunately, if the issue doesn’t present itself in a demo project, there is nothing we can do here without seeing the project.

Don’t feel bad about your workaround either, a similar style workaround is required to get the header to update if you’re setting the listbox to unsorted and want the sort direction indicator to clear.

[quote=420093:@Tim Parnell]Can you provide the project to someone to look at? Unfortunately, if the issue doesn’t present itself in a demo project, there is nothing we can do here without seeing the project.

Don’t feel bad about your workaround either, a similar style workaround is required to get the header to update if you’re setting the listbox to unsorted and want the sort direction indicator to clear.[/quote]
Thanks, Tim, but I don’t have permission from the originator of the code to give it to anyone. Once the project is done, I plan to try to reproduce the issue in a demo project but so far haven’t been able to.

Do you even define the encoding of the string that you get from the response? And do you have AllowLossy true or false in the conversion from xojo.net.httpsocket ?