新增一条记录时不触发事件(其它的记录移动要触发),如何實現?(30分)

  • 主题发起人 小師妹
  • 开始时间

小師妹

Unregistered / Unconfirmed
GUEST, unregistred user!
7. 如何取消一个动作:比如我在新增一条记录时不触发某事件(其它的记录移动要触发該事件);
最好是通用一点的方法,:)
procedure TForm1.Query1BeforeScroll(DataSet: TDataSet);
begin
......
......
end;

procedure TForm1.Query1AfterScroll(DataSet: TDataSet);
begin
......
......
end;
 
判断数据集的状态:
if DataSet.State in [dsInsert,dsEdit] then
...
 
呵呵,这个我也知道啊,
我想问题应该是Query1.state = [dsinsert,dsedit] 时,记录不会移动(鼠标和键盘的记录移动操作无效)
没有通用的办法吗?
我不会啊,
那位师兄帮忙啊?
 
procedure TForm1.Query1BeforeInsert(DataSet: TDataSet);
begin
Query1.OnBeforeScroll:=Query1BeforeScroll;
Query1.OnAfterScroll:=Query1AfterScroll;
end;

procedure TForm1.Query1AfterInsert(DataSet: TDataSet);
begin
Query1.OnBeforeScroll:=nil;
Query1.OnAfterScroll:=nil;
end;

不过OnAfterScroll会在OnAfterInsert以后执行
 
true or false:
if DataSet.State in [dsInsert,dsEdit] then
begin
Query1.OnBeforeScroll:=nil;
Query1.OnAfterScroll:=nil;
end
else
begin
Query1.OnBeforeScroll:=Query1BeforeScroll;
Query1.OnAfterScroll:=Query1AfterScroll;
end;
 
多人接受答案了。
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
908
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
顶部