Why is there no GRID

That’s not the issue, it is the listbox blinking once (at least on Windows) that is annoying.

[quote=14457:@Melvyn Pate]Tried it…I’m usually not foolish enough to argue with Karen on the ListBox because she knows a heck of a lot more about than me, but having the Listbox disappear for 0.75 seconds then reappear is not what I would call desirable.

On a Mac at least it does not disappear as long as you set visible = true by the end of the method… And 0.75sec is for 100,000 rows.

Try it!

  • Karen

Yes, I have it set like that, disappears on Windows. Mac, I’d have to dig out my rMBP under a stack of papers. :wink:

I have never had the Listbox “vanish” when setting VISIBLE=FALSE VISIBLE=TRUE

as long as
a) this all happens inside the same method
b) at no time do you ever call INVALIDATE or REFRESH while VISIBLE=FALSE (that WILL cause it to blink)

Normallly the display is not actually updated until the current thread (ie your method) completes, OR you force a refresh…
So even though you set VISIBLE =FALSE, it remains on the screen until the next system event, and if VISIBLE=TRUE by then, no display change

At least this has always been my expercence with OSX and RealStudio/Xojo

I just put Karen’s code in the sample project, and the grid disappears for about a second while it loads the rows. I think this is a Windows-only issue.

FWIW, I use freezeUpdate/unfreezeUpdate from the Windows Functionality Suite to tackle this on Windows. On the Mac side the OS does the double buffering for you.

Thanks for the tip. Probably workable, but I already own the Einhugur StyleGrid and it works fine in this regard.

I’ve never needed to load so much data into a listbox to have to worry about it as the load time was short enough…

Thanks goodness as I did not realize Windows behavior was different from the Mac in that respect…

The Visible/invisible trick I first saw on the NUG many years ago.

Well now I know to use the WFS methods if I need to do it in the future for Windows.


  • Karen

Thanks for the reply’s guys I guess I have a but of a learning curve just used to the way visual Studio allows me to create a data-table and then attach it to a grid.

Yes, I ran into that when I first started using Real Basic. In Visual Basic, you could create the recordset any way you like then attach it to the grid as the record source and all the columns / rows you requested where there. Then you just added formatting (borders, cell backgrounds, pic overlays, etc…) With Xojo you just have to apply the style and the data at the same time. The Einhugur Grid has an example that stuffs 15,000 rows onto a grid almost instaneously, all done in a loop. It’s lightning fast. I use the ListBox when I need a little more control of what I am painting in individual cells because you can get to the cellpaint events.

I never used VB so I might be missing something, but I think it would be relatively easy to subclass a listbox to take a recordset to do that, though i don’t really see the point as it’s easy and more flexible to do it yourself case by case.

Where it might be useful is maybe as a quick way to display a recordset while developing to make sure your SQL works as expected.

  • Karen

It was more about speed. The VB6 version of my application (in the range of 600-900 rows, 25-45 columns) is still faster than what I have, even with Einhugur. But with processor speeds now the difference is not so much, not as much of an issue as it once was.

when talking about the ListBox for used a Data Grid, please have a look and favourite the following Feedback cases: <https://xojo.com/issue/13421> - “Allow more then 64 Columns in a ListBox” and <https://xojo.com/issue/22203> - “Listbox could need Scrolled event.” (necessery if you want to detect scrolling out of the current bounds of the ListBox). Sure, there are workarounds and 3rd party controls but I would always prefer a built in solution.

It is very easy to subclass a listbox to create a scrolled event, and long as it is OK to fire with every row scrolled or every pixel scrolled horizontally

It is a bit harder (you need to use a timer) to trigger a ScrollFinished event when no longer dragging the thumb… My Ultimate Slider class uses that approach and it can be made to work for a listbox

Once you create the subclass it can be just like having it built in (well except that Xojo makes control subclasses 2nd class citizens in the IDE )

I like that it does this as I was tired of seeing tons of controls I subclassed taking over my library. That being said they should offer a “Pin to Library” or “Favorite” feature to accomplish that.

Actually When doing layout i would rather have all controls in the library( though having them be a in a hierarchical list would be OK to get rid of clutter - I know that would not wok for all VIEWS) and have the library (or inspector) take the place of the Navigator so I could have both the inspector and library visible at the same time…

If All controls were in the library, the Navigator would serve no purpose during layout… But that’s another topic! :wink:

By the way Karen (aka. Ms ListBox Pro :wink: ): You support merged cells in your subclasses if I remember right. Any hints on how to do that?

Just a thought, maybe this could be a workaround till issue is solved. It’s not so nice but I think this will remove the blinking.

Use two Listboxes one as Index 0 and the other one initiated from Window1 open event:
Dim lb as Listbox
lb= New Listbox1

Listbox1(0) is the one you add all new data into and will be invisible during import of data

listbox1(1) is shown (Visible) while you import data to Listbox1(0) and listbox1(1) will contain the previous data from Listbox1(0) before Listbox1(0) importing new Data.

When Listbox1(0) is ready to show new data. You make Listbox1(1) invisible and Listbox1(0) visible

And in the background you copy Listbox1(0) to ListBox1(1) . So next time you have to import new data you swap listbox.

As I said it’s not nice, you just have to make sure the scroll position is the same.

Or You use the Listbox as a window to your data Array. Listbox don’t contain all data but only a small window of the data.

I’ve always suspected it’s painting the cells individually, calculating yourself what goes where. I could be wrong, but that’s how I’d do it.

In all these discussions about the Listbox I always mention the same need I have: Smooth, pixel-level scrolling instead of whole-row scrolling.

For years I’ve been putting off creating my own as I knew it wouldn’t be close to as useable as the built-in listbox is (and the einhugur grid, which I have as well, falls so short in other places, like mousewheel scrolling, I can’t even consider it).

[quote=14827:@Eduardo Gutierrez de Oliveira]I’ve always suspected it’s painting the cells individually, calculating yourself what goes where. I could be wrong, but that’s how I’d do it.

I guess that listbox is my claim to RB/Xojo fame! :wink:

Basically that is the only way to do it as an Xplatform listbox subclass…

I had to override most of the the listbox methods and recreate many of the events because i had to use them.

I use a textArea which I move over cells to allow editing merged cells - and THAT was tricky to get right and support the text entry events! You can call ListBox.Active just as you normally could in a regular listbox.

BTW I do support using CellBackgroundPaint and Celltextpaint for merged cells as work as expected for “regular” cells

It was a lot of coding to provide the expected list box API as well as a decent API for the extra features . Not rocket science but a lot of work (at least for me)

  • Karen