Le 10 sept. 06 à 20:09 Soir, sir_brando a écrit:

Alright, I try it. I've tried goin down the CellBackgroundPaint route before with a gif checkmark. I'm sure it would work, I just cant get it to work right. The bgpaint and textpaint events are some weak points for me. If someone could explain a little more in depth or lead me to a tuturial with some examples that would be awesome. I would like to understand some of these events more. Thanks, I'll play with it some more and see what I come
up with.

Basically, these events can be used like a paint event. In both the CellBackgroundPaint and CellTextPaint events, you have a graphics object (passed as a parameter) where you can draw what you want (like in the Paint event of a canvas).

For example, with this code placed on the CellBackgroundPaint event:

  g.ForeColor=RGB(0,255,255)
  g.FillRect 0,0,g.Width,g.Height

any row which contains text (RB 5.5 and previous) will have a cyan background (at this point, you can still see the selected rows in the user's highlight colour).

About the CellBackgroundPaint event:
you have 3 parameters:

g as graphics, where you draw what you want,
row as integer,column as integer, this is the cell actually being drawn, since the event is called once per cell.

and you have a return value, as boolean.
If you return false, further drawings are done by the system (this is mostly the highlight of the selected rows). If you return true, you tell RB (and the system) that you handled the drawing (you won't see, for example, the selection that the system displays).

The cellbackgroundpaint is made to draw in the background (you certainly figured that out). While you can draw text in the CellBackgroundPaint event (since the graphics object can draw text), it's better to use the CelTextPaint event for that purpose.

About the CellTextPaint event:
you have 5 parameters:

the 3 same parameters as the CellBackgroundPaint event plus:

x and y as integer: this is the recommended starting point to draw your text (this is the coordinate where the system would draw your text). The CellTextPaint event also returns a boolean. If you don't return true (i.e false or no return at all), the text of the cell is also drawn by the system.

Now, for your problem, try this:

in your listbox, put this code in the CellTextPaint event:

  if me.Cell(row,column)="x" then
    g.ForeColor=RGB(255,0,0)
    g.DrawString "0",x,y
  Else
    g.ForeColor=RGB(0,255,0)
    g.DrawString "1",x,y
  end if
  Return True

For this example to work, you list must contain some cells with "x" (which will appear as a "0" red) and anything else (which will appear as a "1" green).

Here's the explanations:

if me.Cell(row,column)="x" then 'Is the current cell an "x" (when the answer is wrong) g.ForeColor=RGB(255,0,0) 'The colour used for the graphics becomes red g.DrawString "0",x,y 'And we draw a "0", at the default coordinates (x,y)
  Else
g.ForeColor=RGB(0,255,0) 'The colour used for the graphics becomes green g.DrawString "1",x,y 'And we draw a "1", at the default coordinates (x,y)
  end if
Return True 'This line is very important. If it is not there, the system will draw the cell's content (like a standard cell), on top of the "1" or "0" you drawn.

Does that help?_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to