Hi I have the following code in my Listbox.CellBackgroundPaint which ONLY highlights the current cell that you click on (I set CLickedRow/ClickedColumn in Cellclick).
// Get Cell Width
Dim RW as integer = me.Column(column).WidthActual
Dim RH as integer = me.RowHeight
if row = ClickedRow AND column = ClickedColumn Then
g.Transparency = 0
g.ForeColor = &cFF3399
g.FillRect 0,0,RW,RH
End if
This works until I click on a cell that is Editable and then the whole row gets highlighted with some default color. I don’t want this behavior and I am struggling to find info on where this is happening/how to disable it.
In my cellbackgroundpaint I return true at the end and the same for my cellclick. I assume this it not correct then for what I am trying to accomplish?
Thanks Tim. I have had Return True at the bottom (left it out by accident on my paste). I am working on trying to mask the row selected highlight with the background cellbackground paint color/transparency.
Ok I got it to work, but I had an interesting thing that was causing me pain. If I use very low or no transparency when coloring the background cells and then when I select the cell the two colors match thus masking my row color.
If I use say a transparency of 70 both colors do not match at all and it looks gross
This is the code with 5% transparency which works.
// Get Cell Width
Dim RW as integer = me.Column(column).WidthActual
Dim RH as integer = me.RowHeight
//Draw the HighlightColor for the Cell Outline for New Row
if row <= CredentialGroupListBox.LastIndex then
g.Transparency = 65
g.PenHeight= 0
g.PenWidth = 1
g.ForeColor = &c000000
g.DrawRect(0, 0, RW,RH)
g.Transparency = 0
end if
//Add a bottom bar to even out the thickness of the last added bottom outline
if row = CredentialGroupListBox.LastIndex+1 then
g.Transparency = 65
g.PenHeight= 0
g.PenWidth = 1
g.ForeColor = &c000000
g.DrawLine(0, 0, RW,0)
g.Transparency = 0
end if
// **************** CODE BELOW that was causing me pain :)
// Fill background Cell color (multicolor) of Only Added Rows
if row <= CredentialGroupListBox.LastIndex Then
g.Transparency = 5 // <--- If I change this to 70 along with the Selected Transparency
If row Mod 2=0 then
g.foreColor= &cFFFF00
else
g.foreColor= &cCCFFFF
end if
g.FillRect 1,1,RW,RH
g.Transparency = 0
End if
if me.selected(Row) Then
g.Transparency = 5 // <--- If I change this to 70 it looks crazy along with the above
If row Mod 2=0 then
g.foreColor= &cFFFF00
else
g.foreColor= &cCCFFFF
end if
g.FillRect 1,1,RW-2,RH-2
g.Transparency = 0
End if
Return true
So If I change both transparencies from 5 to 70 it breaks and looks almost gray. I am not sure why but if you see anything please let me know Thanks again everyone!
Ah I know why… I am still competing against the default Blue that the selected row is highlighting. The more transparent I make it the worse the Blue leaks through… Looks like I can’t use transparency in this situation.
Xojo has already filled the graphics object with the highlight color before it passes it to CellBackgroundPaint, so if you want to use transparency, call ClearRect before you FillRect.