Forum > Other
TStringGrid: what is the difference between OnDrawCell and OnPrepareCanvas event
(1/1)
jcmontherock:
With both of them : can we use TTextStyle, could we change the content of a cell ? A cell color ? Inserting a picture near text in cell ?
wp:
OnPrepareCanvas is called immediately before a cell is painted, all default canvas settings already have been made, and you have a last chance to modify the canvas. All drawing itself is done by the built-in routines using these last canvas settings.
The handler of OnDrawCell, on the other hand, allows you to completely draw a cell by yourself. Since this can be quite complex and users typically only want to change some visual aspects of the cell (background or text color, font style) I usually give preference to OnPrepareCanvas.
Handoko:
@jcmontherock
If you need some code for testing, try these demos:
https://forum.lazarus.freepascal.org/index.php/topic,37181.msg249361.html#msg249361
https://forum.lazarus.freepascal.org/index.php/topic,37181.msg249208.html#msg249208
jcmontherock:
Thanks. I will try these examples.
Navigation
[0] Message Index