你在StringGrid的KeyDown 事件中: with StringGrid do if (Col = 2) and (Row = 1) then Key :=0
KeyDown中无效,要在KeyPress中: procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char); begin if (StringGrid1.Col = 2) and (StringGrid1.Row = 1) then Key := #0 end;
可以试一试 procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean); begin if (Acol=0) then begin canselect := False; exit; end; showmessage(StringGrid1.Cells[acol,arow]); end;
with StringGrid do
if (Col = 2) and (Row = 1) then Key :=0
procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if (StringGrid1.Col = 2) and (StringGrid1.Row = 1) then
Key := #0
end;
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
if (Acol=0) then
begin
canselect := False;
exit;
end;
showmessage(StringGrid1.Cells[acol,arow]);
end;