Επεξεργασία

Κοινή χρήση μέσω


ComponentChangingEventHandler Delegate

Definition

Represents the method that will handle a ComponentChanging event.

public delegate void ComponentChangingEventHandler(System::Object ^ sender, ComponentChangingEventArgs ^ e);
public delegate void ComponentChangingEventHandler(object sender, ComponentChangingEventArgs e);
public delegate void ComponentChangingEventHandler(object? sender, ComponentChangingEventArgs e);
[System.Runtime.InteropServices.ComVisible(true)]
public delegate void ComponentChangingEventHandler(object sender, ComponentChangingEventArgs e);
type ComponentChangingEventHandler = delegate of obj * ComponentChangingEventArgs -> unit
[<System.Runtime.InteropServices.ComVisible(true)>]
type ComponentChangingEventHandler = delegate of obj * ComponentChangingEventArgs -> unit
Public Delegate Sub ComponentChangingEventHandler(sender As Object, e As ComponentChangingEventArgs)

Parameters

sender
Object

The source of the event.

e
ComponentChangingEventArgs

A ComponentChangingEventArgs event that contains the event data.

Attributes

Examples

This example demonstrates registering a ComponentChangingEventHandler and handling the ComponentChanging event.

public:
   void LinkComponentChangingEvent( IComponentChangeService^ changeService )
   {
      // Registers an event handler for the ComponentChanging event.
      changeService->ComponentChanging += gcnew ComponentChangingEventHandler(
         this, &ComponentChangingEventHandlerExample::OnComponentChanging );
   }

private:
   void OnComponentChanging( Object^ sender, ComponentChangingEventArgs^ e )
   {
      // Displays changing component information on the console.
      Console::WriteLine( "Type of the component that is about to change: " +
         e->Component->GetType()->FullName );
      Console::WriteLine( "Name of the member of the component that is about to change: " +
         e->Member->Name );
   }
public void LinkComponentChangingEvent(IComponentChangeService changeService)
{
    // Registers an event handler for the ComponentChanging event.
    changeService.ComponentChanging += new ComponentChangingEventHandler(this.OnComponentChanging);            
}

private void OnComponentChanging(object sender, ComponentChangingEventArgs e)
{
    // Displays changing component information on the console.
    Console.WriteLine("Type of the component that is about to change: "+e.Component.GetType().FullName);      
    Console.WriteLine("Name of the member of the component that is about to change: "+e.Member.Name);                        
}
Public Sub LinkComponentChangingEvent(ByVal changeService As IComponentChangeService)
    ' Registers an event handler for the ComponentChanging event.
    AddHandler changeService.ComponentChanging, AddressOf Me.OnComponentChanging
End Sub

Private Sub OnComponentChanging(ByVal sender As Object, ByVal e As ComponentChangingEventArgs)
    ' Displays changing component information on the console.
    Console.WriteLine(("Type of the component that is about to change: " + e.Component.GetType().FullName))
    Console.WriteLine(("Name of the member of the component that is about to change: " + e.Member.Name))
End Sub

Remarks

When you create a ComponentChangingEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see Handling and Raising Events.

Extension Methods

GetMethodInfo(Delegate)

Gets an object that represents the method represented by the specified delegate.

Applies to

See also