How to refresh a picture in listbox

Is there a simple way to refresh a picture in a listbox?
I have a png which is a green dot, when something goes down another png pic is loaded into cell(0) and a red dot should be shown. That is not happening, only when you select the row the picture changes. I bet there must be another way to refresh the picture automatically. listbox.refresh does not redraw the picture…or the new content of the picture…the picture stays the green dot.

I am rather new and try to get experience with all controls available in Xojo, but this one I could not figure out. I guess I can refresh the cell or redraw the cell, but how do I get the sizes, because I use percentatage for column sizes (listbox.ColumnWidths=“15%,40%,45%”)

Paint the Picture in the CellBackgroundPaint Event for example and it should reflect changes automatically.

But you can always Invalidate a Cell/Row/… to force a redraw.

read the LR and you will find the Listbox Properties… pay attention to ACTUALCOLUMNWIDTH (or something like that)

Jean-Paul, your solution suits my need. Thanks…I read the listbox.Invalidate, but somehow overlooked completely InvalidateCell.

I changed my code and it works like a champ. Thanks

Sascha thanks for putting me already in the correct direction.

Thank you all

As an alternative to using .png’s, just draw your dots. :slight_smile:

I normally put a status code within the Cell itself. Then instead of displaying the status code, I draw some colored dot and a ToolTip with a descriptive text.

In this example, status 10 is ok and status 20 is not ok.

// In CellTextPaint
   If column = 0 And Me.Cell(row, column) = "10" Then
    // Green dot
    g.ForeColor = RGB(50, 200, 50)
    g.FillOval(2, 2, g.Height - 4, g.Height - 4)
    Return True
  ElseIf column = 0 And Me.Cell(row, column) = "20" Then
    // Red dot
    g.ForeColor = RGB(250, 70, 70)
    g.FillOval(2, 2, g.Height - 4, g.Height - 4)
    Return True
  End If