Updating the Right ListBox Row When Data Changes

yeah you only want to invalidate rows that have changed instead of the entire thing

How about adding a Changed property to the object then?

Make the other properties computed properties which set the Changed property. That way the object itself knows it has been changed.

The ListBox checks the Changed property, updates the cell if it is true, and resets the Changed property.

[quote=165640:@Stephen Dodd]That looks like a pretty awesome listbox project you have! Nice.

[/quote]

Thanks…

It’s really my only claim to Xojo fame! :wink:

  • Karen

Karen, you must be using InvalidateCell instead of Invalidate. I can attest that calling Invalidate on a listbox in Windows is a no-op.

Yes I was using InvalidateCell. I thought that as what he was taking about… and it’s all I use on Listboxes.

  • Karen

To force a repaint of the whole listbox in Windows, quickly switch between visible and invisible :

listbox1.visible = false listbox1.visible = true

But InvalidateCell is way more optimized.

To refresh the entire (visible) list, use InvalidateCell(-1,-1).

For those looking for Karen’s cross cell spanning listbox, here’s the updated link: http://katkosoft.xojonews.com/Mergeable%20Listbox%20Page/MergeableCellListbox.html

Outside of getting the right highlight color, that is done in pure Xojo code without declares or plugins, and is a subclass of the xojo listbox.

The Xojo listbox is VERY flexible and you can make it do a lot of different things with some work.

  • Karen

Listbox.visible = true then false does work and causes flicker on Windows
Listbox.InvalidateCell(-1,-1) also works and causes a small amount of flicker in some situations but no more than just changing the value for the listbox row.

@Markus Winter Yes, having a dirty flag to smartly update is a good idea.

Just keep in mind that more than one object property could have been changed, so you have to first set the changed property to false, then invalidate the whole row

True!