procedure TForm1.DBGrid1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var s : string; begin if Button = mbRight then begin showmessage(Format('%d:%d',[x,y])); //根据x,y判断点击的是那一列,代码自己写 s := InputBox('please input new data','value','00'); //然后根据这个dbgrid连接的是query组件还是table组件来写代码 end;end;
我是这么写的,不过接着去怎么写,有点迷茫procedure TForm1.DBGrid1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var s:string; GrdCrd: TGridCoord; begin GrdCrd:= TStringGrid(sender).MouseCoord(x,y); s:=inputbox('修改列','请输入','0'); if GrdCrd.y=0 then case GrdCrd.x of 1:????? 2: end;
后边的修改数据值的语句是 case grdcrd.x of 1: with adoquery do begin close; sql.clear; sql.add('update tablename set fieldname = 某某'); execsql; end;
用adotable 总说 'dataset not in edit or insert mode' 在case里要怎么写才好?
with adotable do begin if not active then open; edit; //然后是你进行更改的代码 end;
Shift: TShiftState; X, Y: Integer);
var
s : string;
begin
if Button = mbRight then
begin
showmessage(Format('%d:%d',[x,y]));
//根据x,y判断点击的是那一列,代码自己写
s := InputBox('please input new data','value','00');
//然后根据这个dbgrid连接的是query组件还是table组件来写代码
end;end;
Shift: TShiftState; X, Y: Integer);
var
s:string;
GrdCrd: TGridCoord;
begin
GrdCrd:= TStringGrid(sender).MouseCoord(x,y);
s:=inputbox('修改列','请输入','0');
if GrdCrd.y=0 then
case GrdCrd.x of
1:?????
2:
end;
case grdcrd.x of
1: with adoquery do
begin
close;
sql.clear;
sql.add('update tablename set fieldname = 某某');
execsql;
end;
begin
if not active then open;
edit;
//然后是你进行更改的代码
end;