procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
  with StringGrid1 do
    if (ACol = 列数) and (ARow = 行数) then
      Options := Options - [goEditing]
    else Options := Options + [goEditing];
end;