TStringGrid.OnPrepareCanvas - when does it fire lazarus / 31-LCL ---------------------------------------------------------------------- Graeme · 2015-07-03 05:45 As the title say, when does OnPrepareCanvas fire in the grand scheme of things. Unfortunately the API Class documentation[1] doesn't elaborate on that. We have a StringGrid with custom drawing using OnDrawCell, but where does OnPrepareCanvas fit in, and why would I use the OnPrepareCanvas, when I could do all the Canvas stuff I need in the OnDrawCell? Links: API Class Documentation http://lazarus- ccr.sourceforge.net/docs/lcl/grids/tcustomgrid.onpreparecanvas.html ---------------------------------------------------------------------- balazsszekely · 2015-07-03 09:31 OnPrepareCanvas is fired just before OnDrawCell(grids.pas-->line 9838). If you use custom drawing, you don't need OnPrepareCanvas(basically it's useless), as you said you can do all the canvas stuff in the OnDrawCell. On default draw instead, just before OnPrepareCanvas is called, a  lot of things are going on, like painting the selected raw, setting canvas font, etc...(for more details see line 3562). ---------------------------------------------------------------------- Graeme · 2015-07-03 10:53 Many thanks for the information. So in our case OnPrepareCanvas is definitely not needed. ---------------------------------------------------------------------- wp · 2015-07-03 11:08 The grid's wiki page is extremely useful for someone trying to learn more about the grid. I definitely prefer it over the "official" documentation. Grid drawing is explained in http://wiki.lazarus.freepascal.org/Grids_Reference_Page#Description_of _grid.27s_drawing_processand http://wiki.lazarus.freepascal.org/Grids_ Reference_Page#What_happens_in_the_TCustomGrid.Paint_method.3F