D dialog1 Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-08 #1 窗體上有多個DBgrid對應多個ADODataSet,和一個button 用一個button,怎樣來刪除多個dataset中的一個的一條記錄?
郭 郭玉梁 Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-08 #2 if DBGrid1.Focused then DBGrid1.DataSource.DataSet.Delete;
Y ysai Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-09 #3 楼上的不行,因为你的button在执行单击事件前就会得到焦点,这样 dbgrid1.focused永远为假,不能删除 只有建立一个模块级的变量,在dbgrid得到焦点时记录它,再在点击中判断并删除 var dbgTemp:TDBGrid; //多个DBGrid都指向这个事件 procedure TForm1.DBGridEnter(Sender: TObject); begin dbgTemp:=Sender; end; procedure TForm1.Button1Click(Sender: TObject); begin dbgTemp.DataSource.DataSet.Delete; end;
楼上的不行,因为你的button在执行单击事件前就会得到焦点,这样 dbgrid1.focused永远为假,不能删除 只有建立一个模块级的变量,在dbgrid得到焦点时记录它,再在点击中判断并删除 var dbgTemp:TDBGrid; //多个DBGrid都指向这个事件 procedure TForm1.DBGridEnter(Sender: TObject); begin dbgTemp:=Sender; end; procedure TForm1.Button1Click(Sender: TObject); begin dbgTemp.DataSource.DataSet.Delete; end;
D daemonking Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-09 #5 for i:=0 to ComponentCount-1 do begin if Components is TDBGrid then begin TDBGrid(Components).DataSource.DataSet.Delete; end; end;
for i:=0 to ComponentCount-1 do begin if Components is TDBGrid then begin TDBGrid(Components).DataSource.DataSet.Delete; end; end;