TStringGrid: draw lines in OnPrepareCanvas? lazarus / 39-Graphics ---------------------------------------------------------------------- stem · 2023-12-29 21:37 Hi, the lines Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i mygrid.Canvas.Pen.Color := clRed;mygrid.Canvas.Line(0, 0, 10, 10); show no effect in the event "OnPrepareCanvas" of my TStringGrid whereas Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i mygrid.Canvas.Brush.Color := $004f4fe8; works perfectly. What am I doing wrong? Thank you. stem ---------------------------------------------------------------------- dsiders · 2023-12-30 01:58 Quote from: stem on December 29, 2023, 10:37:56 pmHi, the lines Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i mygrid.Canvas.Pen.Color := clRed;mygrid.Canvas.Line(0, 0, 10, 10); show no effect in the event "OnPrepareCanvas" of my TStringGrid whereas Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i mygrid.Canvas.Brush.Color := $004f4fe8; works perfectly. What am I doing wrong? Thank you. stem OnPrepareCanvas is not meant for drawing operations... only configuring the canvas with the brush, pen, and font you need to use in DrawCell. https://lazarus- ccr.sourceforge.io/docs/lcl/grids/tcustomgrid.onpreparecanvas.html https://lazarus- ccr.sourceforge.io/docs/lcl/grids/tcustomgrid.ondrawcell.html ---------------------------------------------------------------------- stem · 2024-01-04 21:06 Thank you.