5,507
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
R: TRect;
i:integer;
begin
if ARow<>TRect(StringGrid1.Selection).Top then
exit;
for i:=1 to (Sender as TStringGrid).ColCount-1 do
begin
R:=(Sender as TStringGrid).CellRect(i,ARow);
(Sender as TStringGrid).Canvas.Brush.Color:=clGray;
(Sender as TStringGrid).Canvas.FillRect(Rect);
(Sender as TStringGrid).Canvas.Font.Color:=clBlack;
(Sender as TStringGrid).Canvas.TextOut(r.Left+2,r.Top+2,(Sender as TStringGrid).Cells[i,ARow]);
end;
end;
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
var Rect:TRect;
i:integer;
begin
(Sender as TStringGrid).Refresh;
for i:=1 to (Sender as TStringGrid).ColCount-1 do
begin
Rect:=(Sender as TStringGrid).CellRect(i,ARow);
(Sender as TStringGrid).Canvas.Brush.Color:=clGray;
(Sender as TStringGrid).Canvas.FillRect(Rect);
(Sender as TStringGrid).Canvas.Font.Color:=clBlack;
(Sender as TStringGrid).Canvas.TextOut(rect.Left+2,rect.Top+2,(Sender as TStringGrid).Cells[i,ARow]);
end;
end;