2007. április 2., hétfő
Draw lines over a TStringGrid
Problem/Question/Abstract:
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:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if (aCol = 1) and not (gdFixed in State) then
begin
with (sender as tstringgrid).canvas do
begin
Pen.Color := clBlack;
Pen.Width := 2;
Pen.Style := psSolid;
MoveTo(rect.right - 1, rect.top);
Lineto(rect.right - 1, rect.bottom);
end;
end;
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése