Listbox: disable the Row Selected UI ?

I wrote a picker usinf some Listbox(es).

When I click in a Cell, I already change the clicked cell background and print the text using a custom color.

The trouble is to avoid to get the UI Row Selection color.

Idea(s) ?

PS: I tried to put “everywhere” Me.ListIndex = -1 but this does not works.

See http://documentation.xojo.com/index.php/ListBox.CellClick

Hi Beatrix,

Thank you for the clue.

I already read it, but I will read it once more (what can I skipped there ?)

Return True is what I forgot !

(But I remember to add it in the Paint events…)

Unfortunately, Return True (do the trick for the Row highlight), but stop processing the TextPaint and BackgrountPaint Events… (where I use Return True too)

I already wrote about that, but I add these Events:

CellBackgroundPaint to draw a special background into the Clicked Cell,

CellTextPaint to draw the Text in color (blue) in the Clicked Cell.

Then, I do not want to get the Row selected; so I added:

Me.Selected(Row) = False Me.ListIndex = -1

Another clue ?

This works for me:

Event CellClick(row as Integer, column as Integer, x as Integer, y as Integer) As Boolean Me.EditCell(row, column) Me.ListIndex = -1 // This must come after the EditCell call Return True End

Hi Eli,

thank you for the tip, but I do not want to edit a Cell, just click in it and change its background and text color (without selecting the whole Row).

Hint:
I just was “playing” with that Listbox and discovers that a double click do the trick (and I do not have added a DoubleClick Event !)
For simplicity, I also disabled the KeyDown and KeyUp Events.

BTW: in my previous reply, you can see Me.Selected(Row) = False. I added it because the other line doe not produce the result I was awaiting. I also changed the apparition order (of the lines), but it is still reluctant to do what I want.

In short: I searched a bit before asking (but I may skip a line or two here and there).

me.InvalidateCell(row, -1)
return true

[code]Property mColumn As Integer = -1
Property mRow As Integer = -1

Event CellClick(row as Integer, column as Integer, x as Integer, y as Integer) As Boolean
mRow = row
mColumn = column
Me.InvalidateCell(row, column)
End

Event CellBackgroundPaint(g As Graphics, row As Integer, column As Integer) As Boolean
If mRow = row And mColumn = column Then
g.ForeColor = RGB(255, 0, 0)
Else
g.ForeColor = RGB(255, 255, 255)
End
g.FillRect(0, 0, g.Width, g.Height)
Return True
End

Event CellTextPaint(g As Graphics, row As Integer, column As Integer, x as Integer, y as Inte ger) As Boolean
If mRow = row And mColumn = column Then
g.ForeColor = RGB(255, 255, 0)
Else
g.ForeColor = RGB(0, 0, 0)
End
Return False
End[/code]

Here’s what I actually get (before Eli answer, TIA Eli):

Also, I noticed after I’ve made the screen shot and shrinked it / back to the application, the highlighted color (blue) disappears.

Now, I will check Eli’s advice.

You know if you return True from CellBackgroundPaint it will not draw the selection color, right?

That is not correct. You need to draw the background with FillRect and return True or the selection will be drawn by Xojo (indepent of the return value).

I will check when I will be fully awaken and be back here. Thanks.

Hi all,

the solution seems to be Return True at the end of the CellClick Event. Read the CellClick Event Code below.

[code]Function CellClick(row as Integer, column as Integer, x as Integer, y as Integer) As Boolean
// Refresh the Listbox contents
Me.Invalidate

// Fixe la Cell clique
gSel_Row = Row
gSel_Col = Column

Return True
End Function[/code]

I was near to open my window and drop the computer thru the window and that strange idea comes to my mind.

Edit: all I hope now is this will still works tomorrow (after quit, shutdown and reboot).

Isn’t that what I posted yesterday?

Yes, but what was missing was the Event Name to put it.

Thank you.

Not really:

[quote=351416:@Eli Ott]This works for me:

Event CellClick(row as Integer, column as Integer, x as Integer, y as Integer) As Boolean Me.EditCell(row, column) Me.ListIndex = -1 // This must come after the EditCell call Return True End[/quote]

In fact, I spend a bit of time commented out a line of code, run, and doing so for the whole event.

Then, following this conversation advice, I add Return True (or False), run and test again.

The above allows me to remove these two lines (useless):

Me.Selected(Row) = False Me.ListIndex = -1

One more thank you all.

Markus: I nearly not saw your post (it comes while I was writing this one). I do not wanted to edit the Cell so, I skipped the most important line. Sorry.

So thanks to Markus and Eli too.