Registers event handlers.

Remarks

To hook a control's events, override this method and register your event handlers in one of these ways, or a combination of them:

  • Define and add Event handlers with the IUtilityObject.AddHandler method.

    For a non-routed event:
    _hSelectedDatesChanged = new EventHandler(MyCalendar_SelectedDatesChanged);
    AddEventHandler(UtilityObject.ApplicationObject as UIElement, "SelectedDatesChanged", _hSelectedDatesChanged);

    For a routed event:
    _hGotFocus = new RoutedEventHandler(MyCalendar_GotFocus);
    AddEventHandler(UtilityObject.ApplicationObject, Calendar.GotFocusEvent, _hGotFocus);  

    There is no limit to the number of handlers defined this way.

  • Use the syntax: myApplicationObject.ValueChanged += e;

    If you use this syntax, override IRecord.RecordStop to unsubscribe from Event handling.

It is preferable to use AddHandler rather than the '+=' syntax. If you use AddHandler, your handler is guaranteed to be the first handler in the handlers list. This means your handler gets the Events before other handlers. In addition, if you use AddHandler UFT automatically removes your handler at the end of the Record session.

Syntax

Visual Basic (Declaration)  
Overridable Sub RecordInit() 
C#  
virtual void RecordInit()

See Also