Hi All
Hi All,
can any one help me to restrict call onchange event of dataset while i do its post,first,next,locate etc operation?.
can any one help me to restrict call onchange event of dataset while i do its post,first,next,locate etc operation?.
Is it an option to save the hooked onchange event handler in a local variable, set it to nil, and then restore it after you have completed your operations?
ReplyDeletecreate 2 methods
ReplyDeleteFOnChange: TDataSetEvent;(?)
procedure ClearOnChange(ADataSet: TDataSet);
FOnChange := ADataSet.OnChange;
ADataSet.OnChange := NIL;
procedure RestoreOnChange(ADataSet: TDataSet);
ADataSet.onChange := FOnChange;
or, if you want to go even deeper, and your delphi version supports generics, use a TDictionary and then it doesn't matter the order in which you call Clear|RestoreOnChange.
have fun!
Thanx guys for such a quick response..let me try your views
ReplyDeleteGadhavi Hardip take the above with a grain of salt, I wrote it without trying in IDE.
ReplyDeleteDorin Duminica yes...onchange is event of one of the field of dataset and it has not any event like clear and restoreonchange event.
ReplyDeletehowever thanx for view. let me know if anyother view in your mind
Gadhavi Hardip of course not, you have to create those functions(Create/Restore)
ReplyDeleteand one oneanother solution i have found however it also require not to call onchange event of field so is anyother view to circulate or loop dataset which dont fire onchange event? because next,first and etc fire onchange event
ReplyDeleteDorin Duminica Lars Fosdal Thanx guys..it set perfect in my code...and i finding exactly this.
ReplyDeletethanx for your valuable support.
TOnChange :TFieldNotifyEvent;
ReplyDeleteTOnChange:=wwTTempMatamount.OnChange;
wwTTempMatamount.OnChange:=nil;
//Do post your dataset
wwTTempMatamount.OnChange:=TOnChange;
A very minor point: I would probably name the temp variable previousOnChange, and not TOnChange.
ReplyDeleteTSomeName is a typical pattern for declaring types.
Lars Fosdal Oh..sure...i changing this.thanx for correction.
ReplyDelete