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?.

Comments

  1. 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?

    ReplyDelete
  2. create 2 methods
    FOnChange: 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!

    ReplyDelete
  3. Thanx guys for such a quick response..let me try your views

    ReplyDelete
  4. Gadhavi Hardip take the above with a grain of salt, I wrote it without trying in IDE.

    ReplyDelete
  5. Dorin Duminica  yes...onchange is event of one of the field of dataset and it has not any event like clear and restoreonchange event.
    however thanx for view. let me know if anyother view in your mind

    ReplyDelete
  6. Gadhavi Hardip of course not, you have to create those functions(Create/Restore)

    ReplyDelete
  7. and 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

    ReplyDelete
  8. Dorin Duminica Lars Fosdal Thanx guys..it set perfect in my code...and i finding exactly this.
    thanx for your valuable support.

    ReplyDelete
  9. TOnChange               :TFieldNotifyEvent;

      TOnChange:=wwTTempMatamount.OnChange;
      wwTTempMatamount.OnChange:=nil;
    //Do post your dataset
        wwTTempMatamount.OnChange:=TOnChange;

    ReplyDelete
  10. A very minor point: I would probably name the temp variable previousOnChange, and not TOnChange. 
    TSomeName is a typical pattern for declaring types.

    ReplyDelete
  11. Lars Fosdal Oh..sure...i changing this.thanx for correction.

    ReplyDelete

Post a Comment