Thin line at left of cells in selected row in tstringgrid which is different clr lazarus / 31-LCL ---------------------------------------------------------------------- acpascquestions · 2020-03-19 12:51 Hi, I have a tstringgrid on a form which uses this code to highlight a selected row: procedure TTestForm.testGridDrawCell(Sender: TObject; ACol,   ARow: Integer; Rect: TRect; State: TGridDrawState); begin   testGrid.Canvas.Pen.Color := clNone;   if ARow <> SelectedRow then     testGrid.Canvas.Brush.Color := clWindow   else testGrid.Canvas.Brush.Color := clActiveCaption;   if ColorTSTringList[ARow] = 'Red' then     testGrid.Canvas.Font.Color := clRed;   testGrid.Canvas.Rectangle(Rect.Left, Rect.Top, Rect.Right, Rect.Bottom);   testGrid.Canvas.TextRect(Rect, Rect.Left,Rect.Top,testGrid.Cells[ACol,ARow]); end; For some reason, there is a slightly darker blue rectangle, perhaps 3 pixels wide and the height of the cell in each row which is highlighted (see attached image). Any ideas on this one? ---------------------------------------------------------------------- winni · 2020-03-19 13:38 Hi! The background color of a textrect was discussed here: https://forum.lazarus.freepascal.org/index.php?topic=44978.0 Winni ---------------------------------------------------------------------- howardpc · 2020-03-19 14:01 You don't say where your SelectedRow variable comes from, but it is better to use the parameters provided by the event.Something like this: 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 procedure TForm1.testGridDrawCell(Sender: TObject; aCol, aRow: Integer;  aRect: TRect; aState: TGridDrawState);var  grd: TStringGrid absolute Sender;begin  if not (Sender is TStringGrid) then    Exit;  case (gdSelected in aState) of    True:  grd.Canvas.Brush.Color := clActiveCaption;    False: grd.Canvas.Brush.Color := clWindow;  end;  grd.Canvas.FillRect(aRect);   grd.Canvas.Pen.Color := clNone;  if ColorTSTringList[ARow] = 'Red' then    grd.Canvas.Font.Color := clRed;  grd.Canvas.TextRect(aRect, aRect.Left, aRect.Top, grd.Cells[aCol, aRow]);end; ---------------------------------------------------------------------- jamie · 2020-03-19 23:50 There must be something wrong because RECTANGLE is suppose to fill the interior completely using the current brush style and color.  You shouldn't need to call a separate function to do that..  I didn't notice the widget set that is being used here ? Looks to me like a widget error using rectangle.  However, I also notice no previsions are being made to shrink or offset the RECT for the text so that means it's possible the TextOut could be doing it for what ever reason.. ---------------------------------------------------------------------- acpascquestions · 2020-03-20 00:12 So fiddly, but I got there. I found a post on Stackoverflow which suggested: Rect.Left := Rect.Left-4; and putting this at the start of the ondraw event gets rid of the random line at the left of each cell in the selected row: https://stackoverflow.com/questions/33120729/how-to-fill-cell-of-a- string-grid-using-custom-color Thanks for your prompt replies. ---------------------------------------------------------------------- jamie · 2020-03-20 00:56 Would you mine telling us the Widget set you are using? I suspect there is a problem... The only offsetting you should be doing is that of the Text Rect, that should be enclose a little so not to over write the borders.  For example   for the text operation..   Inc(Rect.Left, 4);   But if even if that worked it shouldn't be drawing the line like that.  so what is your widget set ? Win32, GTK et c?