ComponentEventHandler デリゲート
アセンブリ: System (system.dll 内)

<ComVisibleAttribute(True)> _ Public Delegate Sub ComponentEventHandler ( _ sender As Object, _ e As ComponentEventArgs _ )
[ComVisibleAttribute(true)] public delegate void ComponentEventHandler ( Object sender, ComponentEventArgs e )
[ComVisibleAttribute(true)] public delegate void ComponentEventHandler ( Object^ sender, ComponentEventArgs^ e )
/** @delegate */ /** @attribute ComVisibleAttribute(true) */ public delegate void ComponentEventHandler ( Object sender, ComponentEventArgs e )

ComponentEventHandler デリゲートを作成する場合は、イベントを処理するメソッドを識別してください。イベントをイベント ハンドラに関連付けるには、デリゲートのインスタンスをイベントに追加します。デリゲートを削除しない限り、そのイベントが発生すると常にイベント ハンドラが呼び出されます。イベント ハンドラ デリゲートの詳細については、「イベントとデリゲート」を参照してください。
![]() |
---|
このクラスに適用される HostProtectionAttribute 属性の Resources プロパティの値は、SharedState です。HostProtectionAttribute は、デスクトップ アプリケーション (一般的には、アイコンをダブルクリック、コマンドを入力、またはブラウザに URL を入力して起動するアプリケーション) には影響しません。詳細については、HostProtectionAttribute クラスのトピックまたは「SQL Server プログラミングとホスト保護属性」を参照してください。 |

ComponentEventHandler の登録と ComponentAdded、ComponentAdding、ComponentRemoved、および ComponentRemoving の各イベントの処理の例を次に示します。
Public Sub LinkComponentEvent(ByVal changeService As IComponentChangeService) ' Registers an event handler for the ComponentAdded, ' ComponentAdding, ComponentRemoved, and ComponentRemoving events. AddHandler changeService.ComponentAdded, AddressOf Me.OnComponentEvent AddHandler changeService.ComponentAdding, AddressOf Me.OnComponentEvent AddHandler changeService.ComponentRemoved, AddressOf Me.OnComponentEvent AddHandler changeService.ComponentRemoving, AddressOf Me.OnComponentEvent End Sub Private Sub OnComponentEvent(ByVal sender As Object, ByVal e As ComponentEventArgs) ' Displays changed component information on the console. If Not (e.Component.Site Is Nothing) Then Console.WriteLine(("Name of the component related to the event: " + e.Component.Site.Name)) End If End Sub
public void LinkComponentEvent(IComponentChangeService changeService) { // Registers an event handler for the ComponentAdded, // ComponentAdding, ComponentRemoved, and ComponentRemoving events. changeService.ComponentAdded += new ComponentEventHandler(this.OnComponentEvent); changeService.ComponentAdding += new ComponentEventHandler(this.OnComponentEvent); changeService.ComponentRemoved += new ComponentEventHandler(this.OnComponentEvent); changeService.ComponentRemoving += new ComponentEventHandler(this.OnComponentEvent); } private void OnComponentEvent(object sender, ComponentEventArgs e) { // Displays changed component information on the console. if( e.Component.Site != null ) Console.WriteLine("Name of the component related to the event: "+e.Component.Site.Name); Console.WriteLine("Type of the component related to the event: "+e.Component.GetType().FullName); }
public: void LinkComponentEvent( IComponentChangeService^ changeService ) { // Registers an event handler for the ComponentAdded, // ComponentAdding, ComponentRemoved, and ComponentRemoving events. changeService->ComponentAdded += gcnew ComponentEventHandler( this, &ComponentEventHandlerExample::OnComponentEvent ); changeService->ComponentAdding += gcnew ComponentEventHandler( this, &ComponentEventHandlerExample::OnComponentEvent ); changeService->ComponentRemoved += gcnew ComponentEventHandler( this, &ComponentEventHandlerExample::OnComponentEvent ); changeService->ComponentRemoving += gcnew ComponentEventHandler( this, &ComponentEventHandlerExample::OnComponentEvent ); } private: void OnComponentEvent( Object^ sender, ComponentEventArgs^ e ) { // Displays changed component information on the console. if ( e->Component->Site != nullptr ) { Console::WriteLine( "Name of the component related to the event: " + e->Component->Site->Name ); } Console::WriteLine( "Type of the component related to the event: " + e->Component->GetType()->FullName ); }
public void LinkComponentEvent(IComponentChangeService changeService) { // Registers an event handler for the ComponentAdded, // ComponentAdding, ComponentRemoved, and ComponentRemoving events. changeService.add_ComponentAdded(new ComponentEventHandler(this. OnComponentEvent)); changeService.add_ComponentAdding(new ComponentEventHandler(this. OnComponentEvent)); changeService.add_ComponentRemoved(new ComponentEventHandler(this. OnComponentEvent)); changeService.add_ComponentRemoving(new ComponentEventHandler(this. OnComponentEvent)); } //LinkComponentEvent private void OnComponentEvent(Object sender, ComponentEventArgs e) { // Displays changed component information on the console. if (e.get_Component().get_Site() != null) { Console.WriteLine("Name of the component related to the event: " + e.get_Component().get_Site().get_Name()); } Console.WriteLine("Type of the component related to the event: " + e.get_Component().GetType().get_FullName()); } //OnComponentEvent

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からComponentEventHandler デリゲートを検索する場合は、下記のリンクをクリックしてください。

- ComponentEventHandler デリゲートのページへのリンク