Double drawstring only if column 0 has something

I was reading a thread and downloaded Axel’s example from:

I changed the code to remove the row highlight (commenting to lines and adding 1) on CellBackgroundPaint:

g.ClearRect 0, 0, g.Width, g.Height 'g.ForeColor = &c2F2F2F00 'g.FillRect 0, 0, g.Width , g.Height
and added CellTextPaint with this code:

If Me.selected(row) Then g.ForeColor = &c00000000 g.DrawString(Me.Text,x,y) End If
that way the text is black if the row is selected or not.

Everything works right if I don’t put anything on column 0, if I put something there then it looks like the text is painted twice (bold) not only in that column but everything on the row if the row is selected.

I tried to find what is wrong but I was not able to spot the problem.

Your code says to do that:

It says if the ROW is selected, draw the ROW text in the CELL

If Me.selected(row) Then
g.ForeColor = &c00000000
End If

What you need to do is to draw the text that belongs in the cell, not the text of ‘the whole row’
Try this:

If Me.selected(row) Then g.ForeColor = &c00000000 g.DrawString(me.cell(row,column),x,y) End If

And to prevent the text from being drawn twice, return True to tell Xojo you drew it yourself.

Thank you Jeff, because I used the same text I didn’t catch that. Now I did a test with something different on column 0 and column 1 on the same row and I can see what you mean.

Thank you Tim, that’s needed to not draw twice.

Sorry I can’t select both answers as “This answers my question”

Why are-you using 8 digits to define a color ?

The LR use only 6:

they skip the transparency values.

Emile, its Axel’s fault :slight_smile: the original code use 8 digits so I just changed it to try to do other things.

Thank you for the link.

Edit: I guess if you don’t put the values then 00 is used, I changed the last 2 digits (transparency) to FF and I can’t see the text, then to AA and it is very ‘light’.


That’s it ! Transparency can be fun (if used intentionally or not: pure hazard !).