Listbox header events

Does anyone know a way to force the refresh of a DesktopListobox header cell?

Is anyone aware of any known issues which relate to listbox header events? I have some odd, inconsistent behaviour that I’ll have to try to simplify down.

However I observe that if I click a listbox header, the following happens (as seen in the debugger):

  1. All header cells repainted, paint event fires for each
  2. the HeaderPressed event fires
  3. All header cells are repainted again.

(1) above is a waste of time, for me, as in the HeaderPressed event I change/save some data which affects how the headers are painted.

I don’t use API 2 But… the initial paint event is likely used to highlight the the column header as in button pressed (and eliminate the sort widget from another column if needed) … that said, ideally it should not be redrawing ALL the headers just the ones that need it.

On mouse up the framework needs to repaint that header to remove the click highlight (and draw the sort widget)… but again ideally it would only repaint that one header.


For a classic framework Listbox you could toggle the header and cause it to redraw. I don’t know if this behavior carried over, but it’s worth a try?

// Causes a redraw in classic framework
Listbox.HasHeader = false
Listbox.HasHeader = true

Well now maybe that gives me an idea (for tomorrow, too late for tonight). I paint the sort widget myself and sometimes it doesn’t get eliminated. This is actually a mystery as when painting each header cell I do a FillRectangle first so that ought to paint over the existing sort widget, if any.

My only use of PaintHeaderBackground is to Return True. This has the magical effect of painting the little rectangle that sits above the listbox’es verrical scrollbar - and in the right colour, too. Where it’s getting the colour info from I don’t know.

Ah now there’s another thought. I remember that now (I’d forgotten it) - so thanks for the reminder.

Seems this behaviour is carried over and does the trick. It works OK to use it in the PaintHeaderContent event handler, which I do when the rightmost column has been reached.

1 Like

One thing I don’t understand however is, if I put something inside the PaintHeaderContent event handler which should cause that handler to be called again, why my app doesn’t go into a loop.