Custom Server API References > Mercury.QTP.Slv.CustomServer Namespace > IUtilityObject Interface > Methods > AddHandler Method
Adds an event handler.

Remarks

Handlers added with this method are released by the UFT infrastructure.

Syntax

Visual Basic (Declaration) 
Overridable Sub AddHandler( _
   ByVal element As UIElement, _
   ByVal eventName As String, _
   ByVal handler As MulticastDelegate _
) 
C# 
virtual void AddHandler( 
   UIElement element,
   string eventName,
   MulticastDelegate handler
)

Parameters

element
The control on which to add the event handler. This is generally the IUtilityObject.ApplicationObject but may be a child control or any other control.
eventName

The name of the event to handle, for example "SelectedDatesChanged" for the SelectedDatesChanged event on a calendar.

handler
The event handler.

Example

C#Copy Code
private RoutedEventHandler _hExpanded; 
 
RecordInit() 

                _hExpanded = new RoutedEventHandler(OnExpanded); 
                UtilityObject.AddHandler(UtilityObject.ApplicationObject as UIElement, "Expanded", hExpanded); 

 
private void OnExpanded(object sender, RoutedEventArgs arg) 

}

See Also