Please save me, the whole ListBox cell color drawing concept is beyond my perception ability Haha, I just can’t get its damn logic (Sorry)
I’ve put this code in the ListBox.CellBackgroundPaint
If Dclicked Then
Select Case Row
Case Me.SelectedRowIndex
g.AntiAlias = False
g.ForeColor = RGB(0, 255, 0, 150)
g.FillRectangle(0, 0, g.Width, g.Height)
End Select
Dclicked = False
Return True
End If
While in the ListBox.DoubleClick event I just send:Dclicked = True
It works nice to color the clicked cell the moment I double click it but as soon as I move the to another cell it reset the color to its previous state.
I also have the odd-even row coloring thing in the CellBackgroundPaint but I don’t think it matters or changes anything.
When I finally get it to work I will also like to reset the colors every time I clear the list or when I re-populate the list but I’m not there yet;)
this changes the value of ME.SELECTEDROWINDEX, what you need to do is use DCLICKED to hold the ROW number you doubleclicked , not just the fact that you did (and don’t reset it inside the paint event otherwise the same result will occur
Thanks @Dave S but unfortunately I’m so lost in the ListBox and color drawing concept that I just can’t point myself to the right command that should be used to specify a location in the list box for the g.FillRectangle to create the color drawing.
From your words I understand I should change the DCLICKED Var to Integer and use it for both checking if it was clicked (if DCLICKED > 0) and to hold the clicked row number: DCLICKED = Me.SelectedRowIndex but that as far as I can get with my limited understanding in list box handling.
g.AntiAlias = False
If row=Dclicked Then
g.ForeColor = RGB(0, 255, 0, 150)
else
g.forecolor=color.white // NOT the dbl clicked row
end if
g.FillRectangle(0, 0, g.Width, g.Height)
Return True
End If
[quote=467743:@Dave S]
g.AntiAlias = False
If row=Dclicked Then
g.ForeColor = RGB(0, 255, 0, 150)
else
g.forecolor=color.white // NOT the dbl clicked row
end if
g.FillRectangle(0, 0, g.Width, g.Height)
Return True
End If
[/quote]
I’m Amazed!
It works and still I have zero idea how although the answer is right in front of me, so frustrating, I have to learn how it works.
Many thanks Dave, I hope I’ll be able to reset the colors when I re-populate the list without bothering you once again
Basically, you have to keep track of the Cell you want to color, then color it.
So, in CellTag, you place a color, and in CellBackgroundPaint, you draw the Cell using that color (if CellTag have a Color) for that Cell.
Is-it clear now ?[/quote]
That could have been nice if it wasn’t already occupied with a much more important information for later use FolderItem(i).NativePath