Recent

Author Topic: TStringGrid: what is the difference between OnDrawCell and OnPrepareCanvas event  (Read 316 times)

jcmontherock

  • Sr. Member
  • ****
  • Posts: 294
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 ?
Windows 11 UTF8-64 - Lazarus 4.0-64 - FPC 3.2.2

wp

  • Hero Member
  • *****
  • Posts: 12784
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

  • Hero Member
  • *****
  • Posts: 5417
  • My goal: build my own game engine using Lazarus

jcmontherock

  • Sr. Member
  • ****
  • Posts: 294
Thanks. I will try these examples.
Windows 11 UTF8-64 - Lazarus 4.0-64 - FPC 3.2.2

 

TinyPortal © 2005-2018