Author: Tomas Rutkauskas
I have a TStringGrid with objects put in big coloumns of 4 normal columns. How can
I draw a black line from top to bottom over the gray line that the grid itself
draws?
Answer:
Handle the OnDrawCell event for the grid. If the cell you are asked to draw is in
the column in question you draw the part of the line that crosses the cell:
1 2 procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
3 Rect: TRect; State: TGridDrawState);
4 begin5 if (aCol = 1) andnot (gdFixed in State) then6 begin7 with (sender as tstringgrid).canvas do8 begin9 Pen.Color := clBlack;
10 Pen.Width := 2;
11 Pen.Style := psSolid;
12 MoveTo(rect.right - 1, rect.top);
13 Lineto(rect.right - 1, rect.bottom);
14 end;
15 end;
16 end;