1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| procedure TForm1.Button1Click(Sender: TObject);
var I, J: Integer;
begin
for J := 0 to StringGrid1.ColCount -1 do
for I := 0 to StringGrid1.RowCount -1 do
if (I = 0) or (J=0) then
StringGrid1.Cells[J, I] := Format('Item [%d][%d]', [J, I]);
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if (ACol = 0) or (aRow =0) then
begin
with StringGrid1 do
begin
if (gdSelected in State) or (gdFocused in State) then
Frame3D(Canvas,Rect, clBlack, clWhite, 1)
else
Frame3D(Canvas,Rect, clWhite , clBlack,1);
Canvas.Brush.Color := StringGrid1.FixedColor;
Canvas.FillRect(Rect);
if (gdSelected in State) then
Canvas.TextRect(Rect, Rect.Left +1, Rect.Top +1, Cells[ACol, ARow])
else
Canvas.TextRect(Rect, Rect.Left +2, Rect.Top +2,Cells[ACol, ARow]);
end;
end;
end; |
Partager