unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids;type TForm1 = class(TForm) StringGrid1: TStringGrid; procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean); procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); private { Private declarations } public { Public declarations } end;var Form1: TForm1; IndexACol, IndexARow: Integer;implementation{$R *.dfm}procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean);begin IndexACol := ACol; IndexARow := ARow;end;procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);var i, x1, x2, y1, y2: Integer; lastc: Tcolor;begin // if (IndexACol= 0) and (IndexARow = 0) then exit; if (IndexACol = ACol) and (IndexARow = ARow) then begin x1 := 0; for i := 0 to ACol - 1 do begin x1 := x1 + 1; x1 := x1 + StringGrid1.ColWidths; end; x2 := x1 + StringGrid1.ColWidths[ACol]; y1 := 0; for i := 0 to ARow - 1 do begin y1 := y1 + 1; y1 := y1 + StringGrid1.RowHeights; end; y2 := y1 + StringGrid1.RowHeights[ARow]; lastc := StringGrid1.Canvas.Pen.Color; StringGrid1.Canvas.Pen.Color := clred; StringGrid1.Canvas.Pen.Width := 2; StringGrid1.Canvas.Rectangle(x1 +1 , y1 +1 , x2 + 1, y2 +1 ); StringGrid1.Canvas.Pen.Color := lastc; end;end;end.