procedure TfrmServerSetup.ColumnModify(n:Integer;str:string;adotb:TADOTable);
begin
with adotb do
while not eof do
begin
if not active then open;
edit;
adotb.fieldvalues['time'+inttostr(n-1)]:=str;
adotb.Next;
end;
end;procedure TfrmServerSetup.DBAdvStringGrid1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
Var
s:string;
GrdCrd: TGridCoord;
begin
GrdCrd := TStringGrid(Sender).MouseCoord(X, Y);
if Button=mbRight then
begin
s:=inputbox('修改列值','输入值','0');
ColumnModify(GrdCrd.X,s,adotable1);
end;
end;procedure TfrmServerSetup.DBAdvStringGrid2MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
Var
s:string;
GrdCrd: TGridCoord;
begin
GrdCrd := TStringGrid(Sender).MouseCoord(X, Y);
if Button=mbRight then
begin
s:=inputbox('修改列值','输入值','0');
ColumnModify(GrdCrd.X,s,adotable2);
end;
end;.........
.........这下面还有N个DBAdvStringGrid2MouseDown事件,每个的写法都基本一样,只是有不同的DBAdvStringGrid,还有参数不同,如果有多少个grid就写多少个mousedown事件,这样太罗嗦,而且会写很长,寻求简化复用的办法,众大虾指点一下
begin
with adotb do
while not eof do
begin
if not active then open;
edit;
adotb.fieldvalues['time'+inttostr(n-1)]:=str;
adotb.Next;
end;
end;procedure TfrmServerSetup.DBAdvStringGrid1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
Var
s:string;
GrdCrd: TGridCoord;
begin
GrdCrd := TStringGrid(Sender).MouseCoord(X, Y);
if Button=mbRight then
begin
s:=inputbox('修改列值','输入值','0');
ColumnModify(GrdCrd.X,s,adotable1);
end;
end;procedure TfrmServerSetup.DBAdvStringGrid2MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
Var
s:string;
GrdCrd: TGridCoord;
begin
GrdCrd := TStringGrid(Sender).MouseCoord(X, Y);
if Button=mbRight then
begin
s:=inputbox('修改列值','输入值','0');
ColumnModify(GrdCrd.X,s,adotable2);
end;
end;.........
.........这下面还有N个DBAdvStringGrid2MouseDown事件,每个的写法都基本一样,只是有不同的DBAdvStringGrid,还有参数不同,如果有多少个grid就写多少个mousedown事件,这样太罗嗦,而且会写很长,寻求简化复用的办法,众大虾指点一下
你在DBAdvStringGrid2的onmousedown方法里下拉选择DBAdvStringGrid1的mousedown方法就行
根据sender 的不同来判断具体是哪个grid
case TDBAdvStringGrid(sender).tag of
1:....
2:....