判断鼠标左右键在mouse的事件里面 例如: procedure TForm1.StringGrid1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Button=mbRight then//右键end;
procedure TForm1.StringGrid1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var ACol,ARow:integer; begin if Button=mbRight then //右键按下 begin StringGrid1.MouseToCell(X,Y,ACol,ARow); //判断这时在哪个格子 if Acol,ARow满足你的条件 then begin //做你想做的 end; end; end;
例如:
procedure TForm1.StringGrid1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button=mbRight then//右键end;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
ACol,ARow:integer;
begin
if Button=mbRight then //右键按下
begin
StringGrid1.MouseToCell(X,Y,ACol,ARow); //判断这时在哪个格子
if Acol,ARow满足你的条件 then
begin
//做你想做的
end;
end;
end;