IComponentChangeService 인터페이스
구성 요소를 추가, 변경, 제거하거나 구성 요소의 이름을 바꾸는 이벤트에 대한 이벤트 처리기를 추가하고 제거하는 인터페이스를 제공하며 ComponentChanged 또는 ComponentChanging 이벤트를 발생시키는 메서드를 제공합니다.
네임스페이스: System.ComponentModel.Design
어셈블리: System(system.dll)
구문
‘선언
<ComVisibleAttribute(True)> _
Public Interface IComponentChangeService
‘사용 방법
Dim instance As IComponentChangeService
[ComVisibleAttribute(true)]
public interface IComponentChangeService
[ComVisibleAttribute(true)]
public interface class IComponentChangeService
/** @attribute ComVisibleAttribute(true) */
public interface IComponentChangeService
ComVisibleAttribute(true)
public interface IComponentChangeService
설명
IComponentChangeService에서는 다음 이벤트를 처리하는 메서드를 나타내는 데 사용할 수 있는 인터페이스를 제공합니다.
구성 요소가 추가되면 발생하는 ComponentAdded입니다.
구성 요소가 추가되기 직전에 발생하는 ComponentAdding입니다.
구성 요소가 변경되면 발생하는 ComponentChanged입니다.
구성 요소가 변경되기 직전에 발생하는 ComponentChanging입니다.
구성 요소가 제거되면 발생하는 ComponentRemoved입니다.
구성 요소가 제거되기 직전에 발생하는 ComponentRemoving입니다.
구성 요소의 이름을 바꾸면 발생하는 ComponentRename입니다.
일반적으로 디자인 환경은 이러한 구성 요소에 추가, 변경, 제거 및 이름 바꾸기 이벤트를 발생시킵니다. 구성 요소에 영향을 미치는 디자인 타임 동작에 대한 실행 취소 및 다시 실행 기능을 제공하기 위해 DesignerTransaction 개체를 사용할 때 디자이너에서 이 인터페이스의 메서드를 호출해야 합니다. 자세한 내용은 DesignerTransaction 설명서를 참조하십시오. 일반적으로 루트 디자이너에서만 이러한 변경 통지를 처리합니다.
또한 이 서비스에서는 구성 요소가 변경된 이벤트나 구성 요소를 변경 중인 이벤트를 발생시키는 메서드를 제공합니다. PropertyDescriptor 또는 구성 요소에서는 OnComponentChanged 또는 OnComponentChanging 메서드를 사용하여 구성 요소가 각각 변경되었거나 변경 중임을 나타낼 수 있습니다.
예제
다음 예제에서는 IComponentChangeService 인터페이스를 사용하여 디자인 모드에서 구성 요소의 추가, 제거 및 변경에 대한 통지를 받습니다.
Imports System
Imports System.Data
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Windows.Forms
' This sample illustrates how to use the IComponentChangeService interface
' to handle component change events. The ComponentClass control attaches
' event handlers when it is sited in a document, and displays a message
' when notification that a component has been added, removed, or changed
' is received from the IComponentChangeService.
' To run this sample, add the ComponentClass control to a Form and
' add, remove, or change components to see the behavior of the
' component change event handlers.
Namespace IComponentChangeServiceExample
_
Public Class ComponentClass
Inherits System.Windows.Forms.UserControl
Private components As System.ComponentModel.Container = Nothing
Private listBox1 As System.Windows.Forms.ListBox
Private m_changeService As IComponentChangeService
Public Sub New()
InitializeComponent()
End Sub
Private Sub InitializeComponent()
Me.listBox1 = New System.Windows.Forms.ListBox()
Me.SuspendLayout()
' listBox1.
Me.listBox1.Location = New System.Drawing.Point(24, 16)
Me.listBox1.Name = "listBox1"
Me.listBox1.Size = New System.Drawing.Size(576, 277)
Me.listBox1.TabIndex = 0
' ComponentClass.
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.listBox1})
Me.Name = "ComponentClass"
Me.Size = New System.Drawing.Size(624, 320)
Me.ResumeLayout(False)
End Sub
' This override allows the control to register event handlers for IComponentChangeService events
' at the time the control is sited, which happens only in design mode.
Public Overrides Property Site() As ISite
Get
Return MyBase.Site
End Get
Set(ByVal Value As ISite)
' Clear any component change event handlers.
ClearChangeNotifications()
' Set the new Site value.
MyBase.Site = Value
m_changeService = CType(GetService(GetType(IComponentChangeService)), IComponentChangeService)
' Register event handlers for component change events.
RegisterChangeNotifications()
End Set
End Property
Private Sub ClearChangeNotifications()
' The m_changeService value is null when not in design mode,
' as the IComponentChangeService is only available at design time.
m_changeService = CType(GetService(GetType(IComponentChangeService)), IComponentChangeService)
' Clear our the component change events to prepare for re-siting.
If Not (m_changeService Is Nothing) Then
RemoveHandler m_changeService.ComponentChanged, AddressOf OnComponentChanged
RemoveHandler m_changeService.ComponentChanging, AddressOf OnComponentChanging
RemoveHandler m_changeService.ComponentAdded, AddressOf OnComponentAdded
RemoveHandler m_changeService.ComponentAdding, AddressOf OnComponentAdding
RemoveHandler m_changeService.ComponentRemoved, AddressOf OnComponentRemoved
RemoveHandler m_changeService.ComponentRemoving, AddressOf OnComponentRemoving
RemoveHandler m_changeService.ComponentRename, AddressOf OnComponentRename
End If
End Sub
Private Sub RegisterChangeNotifications()
' Register the event handlers for the IComponentChangeService events
If Not (m_changeService Is Nothing) Then
AddHandler m_changeService.ComponentChanged, AddressOf OnComponentChanged
AddHandler m_changeService.ComponentChanging, AddressOf OnComponentChanging
AddHandler m_changeService.ComponentAdded, AddressOf OnComponentAdded
AddHandler m_changeService.ComponentAdding, AddressOf OnComponentAdding
AddHandler m_changeService.ComponentRemoved, AddressOf OnComponentRemoved
AddHandler m_changeService.ComponentRemoving, AddressOf OnComponentRemoving
AddHandler m_changeService.ComponentRename, AddressOf OnComponentRename
End If
End Sub
' This method handles the OnComponentChanged event to display a notification.
Private Sub OnComponentChanged(ByVal sender As Object, ByVal ce As ComponentChangedEventArgs)
If Not (ce.Component Is Nothing) And Not (CType(ce.Component, IComponent).Site Is Nothing) And Not (ce.Member Is Nothing) Then
OnUserChange(("The " + ce.Member.Name + " member of the " + CType(ce.Component, IComponent).Site.Name + " component has been changed."))
End If
End Sub
' This method handles the OnComponentChanging event to display a notification.
Private Sub OnComponentChanging(ByVal sender As Object, ByVal ce As ComponentChangingEventArgs)
If Not (ce.Component Is Nothing) And Not (CType(ce.Component, IComponent).Site Is Nothing) And Not (ce.Member Is Nothing) Then
OnUserChange(("The " + ce.Member.Name + " member of the " + CType(ce.Component, IComponent).Site.Name + " component is being changed."))
End If
End Sub
' This method handles the OnComponentAdded event to display a notification.
Private Sub OnComponentAdded(ByVal sender As Object, ByVal ce As ComponentEventArgs)
OnUserChange(("A component, " + ce.Component.Site.Name + ", has been added."))
End Sub
' This method handles the OnComponentAdding event to display a notification.
Private Sub OnComponentAdding(ByVal sender As Object, ByVal ce As ComponentEventArgs)
OnUserChange(("A component of type " + (CType(ce.Component, Component)).GetType().FullName + " is being added."))
End Sub
' This method handles the OnComponentRemoved event to display a notification.
Private Sub OnComponentRemoved(ByVal sender As Object, ByVal ce As ComponentEventArgs)
OnUserChange(("A component, " + ce.Component.Site.Name + ", has been removed."))
End Sub
' This method handles the OnComponentRemoving event to display a notification.
Private Sub OnComponentRemoving(ByVal sender As Object, ByVal ce As ComponentEventArgs)
OnUserChange(("A component, " + ce.Component.Site.Name + ", is being removed."))
End Sub
' This method handles the OnComponentRename event to display a notification.
Private Sub OnComponentRename(ByVal sender As Object, ByVal ce As ComponentRenameEventArgs)
OnUserChange(("A component, " + ce.OldName + ", was renamed to " + ce.NewName + "."))
End Sub
' This method adds a specified notification message to the control's listbox.
Private Sub OnUserChange(ByVal [text] As String)
listBox1.Items.Add([text])
End Sub
' Clean up any resources being used.
Protected Overloads Sub Dispose(ByVal disposing As Boolean)
If disposing Then
ClearChangeNotifications()
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
End Class
End Namespace
using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Windows.Forms;
/* This sample illustrates how to use the IComponentChangeService interface
to handle component change events. The ComponentClass control attaches
event handlers when it is sited in a document, and displays a message
when notification that a component has been added, removed, or changed
is received from the IComponentChangeService.
To run this sample, add the ComponentClass control to a Form and
add, remove, or change components to see the behavior of the
component change event handlers. */
namespace IComponentChangeServiceExample
{
public class ComponentClass : System.Windows.Forms.UserControl
{
private System.ComponentModel.Container components = null;
private System.Windows.Forms.ListBox listBox1;
private IComponentChangeService m_changeService;
public ComponentClass()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
// listBox1.
this.listBox1.Location = new System.Drawing.Point(24, 16);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(576, 277);
this.listBox1.TabIndex = 0;
// ComponentClass.
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.listBox1});
this.Name = "ComponentClass";
this.Size = new System.Drawing.Size(624, 320);
this.ResumeLayout(false);
}
// This override allows the control to register event handlers for IComponentChangeService events
// at the time the control is sited, which happens only in design mode.
public override ISite Site
{
get
{
return base.Site;
}
set
{
// Clear any component change event handlers.
ClearChangeNotifications();
// Set the new Site value.
base.Site = value;
m_changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
// Register event handlers for component change events.
RegisterChangeNotifications();
}
}
private void ClearChangeNotifications()
{
// The m_changeService value is null when not in design mode,
// as the IComponentChangeService is only available at design time.
m_changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
// Clear our the component change events to prepare for re-siting.
if (m_changeService != null)
{
m_changeService.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged);
m_changeService.ComponentChanging -= new ComponentChangingEventHandler(OnComponentChanging);
m_changeService.ComponentAdded -= new ComponentEventHandler(OnComponentAdded);
m_changeService.ComponentAdding -= new ComponentEventHandler(OnComponentAdding);
m_changeService.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved);
m_changeService.ComponentRemoving -= new ComponentEventHandler(OnComponentRemoving);
m_changeService.ComponentRename -= new ComponentRenameEventHandler(OnComponentRename);
}
}
private void RegisterChangeNotifications()
{
// Register the event handlers for the IComponentChangeService events
if (m_changeService != null)
{
m_changeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
m_changeService.ComponentChanging += new ComponentChangingEventHandler(OnComponentChanging);
m_changeService.ComponentAdded += new ComponentEventHandler(OnComponentAdded);
m_changeService.ComponentAdding += new ComponentEventHandler(OnComponentAdding);
m_changeService.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved);
m_changeService.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving);
m_changeService.ComponentRename += new ComponentRenameEventHandler(OnComponentRename);
}
}
/* This method handles the OnComponentChanged event to display a notification. */
private void OnComponentChanged(object sender, ComponentChangedEventArgs ce)
{
if( ce.Component != null && ((IComponent)ce.Component).Site != null && ce.Member != null )
OnUserChange("The " + ce.Member.Name + " member of the " + ((IComponent)ce.Component).Site.Name + " component has been changed.");
}
/* This method handles the OnComponentChanging event to display a notification. */
private void OnComponentChanging(object sender, ComponentChangingEventArgs ce)
{
if( ce.Component != null && ((IComponent)ce.Component).Site != null && ce.Member != null )
OnUserChange("The " + ce.Member.Name + " member of the " + ((IComponent)ce.Component).Site.Name + " component is being changed.");
}
/* This method handles the OnComponentAdded event to display a notification. */
private void OnComponentAdded(object sender, ComponentEventArgs ce)
{
OnUserChange("A component, " + ce.Component.Site.Name + ", has been added.");
}
/* This method handles the OnComponentAdding event to display a notification. */
private void OnComponentAdding(object sender, ComponentEventArgs ce)
{
OnUserChange("A component of type " + ce.Component.GetType().FullName + " is being added.");
}
/* This method handles the OnComponentRemoved event to display a notification. */
private void OnComponentRemoved(object sender, ComponentEventArgs ce)
{
OnUserChange("A component, " + ce.Component.Site.Name + ", has been removed.");
}
/* This method handles the OnComponentRemoving event to display a notification. */
private void OnComponentRemoving(object sender, ComponentEventArgs ce)
{
OnUserChange("A component, " + ce.Component.Site.Name + ", is being removed.");
}
/* This method handles the OnComponentRename event to display a notification. */
private void OnComponentRename(object sender, ComponentRenameEventArgs ce)
{
OnUserChange("A component, " + ce.OldName + ", was renamed to " + ce.NewName +".");
}
// This method adds a specified notification message to the control's listbox.
private void OnUserChange(string text)
{
listBox1.Items.Add(text);
}
// Clean up any resources being used.
protected override void Dispose( bool disposing )
{
if( disposing )
{
ClearChangeNotifications();
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
}
}
#using <system.dll>
#using <system.windows.forms.dll>
#using <system.drawing.dll>
using namespace System;
using namespace System::Drawing;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::Windows::Forms;
/* This sample illustrates how to use the IComponentChangeService interface
to handle component change events. The ComponentClass control attaches
event handlers when it is sited in a document, and displays a message
when notification that a component has been added, removed, or changed
is received from the IComponentChangeService.
To run this sample, add the ComponentClass control to a Form and
add, remove, or change components to see the behavior of the
component change event handlers. */
public ref class ComponentClass: public UserControl
{
private:
System::ComponentModel::Container^ components;
ListBox^ listBox1;
IComponentChangeService^ m_changeService;
void InitializeComponent()
{
this->listBox1 = gcnew ListBox;
this->SuspendLayout();
// listBox1.
this->listBox1->Location = System::Drawing::Point( 24, 16 );
this->listBox1->Name = "listBox1";
this->listBox1->Size = System::Drawing::Size( 576, 277 );
this->listBox1->TabIndex = 0;
// ComponentClass.
array<Control^>^myArray = {listBox1};
this->Controls->AddRange( myArray );
this->Name = "ComponentClass";
this->Size = System::Drawing::Size( 624, 320 );
this->ResumeLayout( false );
}
void ClearChangeNotifications()
{
// The m_changeService value is 0 when not in design mode,
// as the IComponentChangeService is only available at design time.
m_changeService = dynamic_cast<IComponentChangeService^>(GetService( IComponentChangeService::typeid ));
// Clear our the component change events to prepare for re-siting.
if ( m_changeService != nullptr )
{
m_changeService->ComponentChanged -= gcnew ComponentChangedEventHandler( this, &ComponentClass::OnComponentChanged );
m_changeService->ComponentChanging -= gcnew ComponentChangingEventHandler( this, &ComponentClass::OnComponentChanging );
m_changeService->ComponentAdded -= gcnew ComponentEventHandler( this, &ComponentClass::OnComponentAdded );
m_changeService->ComponentAdding -= gcnew ComponentEventHandler( this, &ComponentClass::OnComponentAdding );
m_changeService->ComponentRemoved -= gcnew ComponentEventHandler( this, &ComponentClass::OnComponentRemoved );
m_changeService->ComponentRemoving -= gcnew ComponentEventHandler( this, &ComponentClass::OnComponentRemoving );
m_changeService->ComponentRename -= gcnew ComponentRenameEventHandler( this, &ComponentClass::OnComponentRename );
}
}
void RegisterChangeNotifications()
{
// Register the event handlers for the IComponentChangeService events
if ( m_changeService != nullptr )
{
m_changeService->ComponentChanged += gcnew ComponentChangedEventHandler( this, &ComponentClass::OnComponentChanged );
m_changeService->ComponentChanging += gcnew ComponentChangingEventHandler( this, &ComponentClass::OnComponentChanging );
m_changeService->ComponentAdded += gcnew ComponentEventHandler( this, &ComponentClass::OnComponentAdded );
m_changeService->ComponentAdding += gcnew ComponentEventHandler( this, &ComponentClass::OnComponentAdding );
m_changeService->ComponentRemoved += gcnew ComponentEventHandler( this, &ComponentClass::OnComponentRemoved );
m_changeService->ComponentRemoving += gcnew ComponentEventHandler( this, &ComponentClass::OnComponentRemoving );
m_changeService->ComponentRename += gcnew ComponentRenameEventHandler( this, &ComponentClass::OnComponentRename );
}
}
/* This method handles the OnComponentChanged event to display a notification. */
void OnComponentChanged( Object^ /*sender*/, ComponentChangedEventArgs^ ce )
{
if ( ce->Component != nullptr && static_cast<IComponent^>(ce->Component)->Site != nullptr && ce->Member != nullptr )
OnUserChange( "The " + ce->Member->Name + " member of the " + static_cast<IComponent^>(ce->Component)->Site->Name + " component has been changed." );
}
/* This method handles the OnComponentChanging event to display a notification. */
void OnComponentChanging( Object^ /*sender*/, ComponentChangingEventArgs^ ce )
{
if ( ce->Component != nullptr && static_cast<IComponent^>(ce->Component)->Site != nullptr && ce->Member != nullptr )
OnUserChange( "The " + ce->Member->Name + " member of the " + static_cast<IComponent^>(ce->Component)->Site->Name + " component is being changed." );
}
/* This method handles the OnComponentAdded event to display a notification. */
void OnComponentAdded( Object^ /*sender*/, ComponentEventArgs^ ce )
{
OnUserChange( "A component, " + ce->Component->Site->Name + ", has been added." );
}
/* This method handles the OnComponentAdding event to display a notification. */
void OnComponentAdding( Object^ /*sender*/, ComponentEventArgs^ ce )
{
OnUserChange( "A component of type " + ce->Component->GetType()->FullName + " is being added." );
}
/* This method handles the OnComponentRemoved event to display a notification. */
void OnComponentRemoved( Object^ /*sender*/, ComponentEventArgs^ ce )
{
OnUserChange( "A component, " + ce->Component->Site->Name + ", has been removed." );
}
/* This method handles the OnComponentRemoving event to display a notification. */
void OnComponentRemoving( Object^ /*sender*/, ComponentEventArgs^ ce )
{
OnUserChange( "A component, " + ce->Component->Site->Name + ", is being removed." );
}
/* This method handles the OnComponentRename event to display a notification. */
void OnComponentRename( Object^ /*sender*/, ComponentRenameEventArgs^ ce )
{
OnUserChange( "A component, " + ce->OldName + ", was renamed to " + ce->NewName + "." );
}
// This method adds a specified notification message to the control's listbox.
void OnUserChange( String^ text )
{
listBox1->Items->Add( text );
}
public:
ComponentClass()
{
InitializeComponent();
}
property ISite^ Site
{
// This override allows the control to register event handlers for IComponentChangeService events
// at the time the control is sited, which happens only in design mode.
virtual ISite^ get() override
{
return Site;
}
virtual void set( ISite^ value ) override
{
// Clear any component change event handlers.
ClearChangeNotifications();
// Set the new Site value.
Site = value;
m_changeService = static_cast<IComponentChangeService^>(GetService( IComponentChangeService::typeid ));
// Register event handlers for component change events.
RegisterChangeNotifications();
}
}
// Clean up any resources being used.
public:
~ComponentClass()
{
ClearChangeNotifications();
if ( components != nullptr )
{
delete components;
}
}
};
import System.*;
import System.Data.*;
import System.Drawing.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.ComponentModel.Design.*;
import System.Windows.Forms.*;
/* This sample illustrates how to use the IComponentChangeService interface
to handle component change events. The ComponentClass control attaches
event handlers when it is sited in a document, and displays a message
when notification that a component has been added, removed, or changed
is received from the IComponentChangeService.
To run this sample, add the ComponentClass control to a Form and
add, remove, or change components to see the behavior of the
component change event handlers.
*/
public class ComponentClass extends System.Windows.Forms.UserControl
{
private System.ComponentModel.Container components = null;
private System.Windows.Forms.ListBox listBox1;
private IComponentChangeService m_changeService;
public ComponentClass()
{
InitializeComponent();
} //ComponentClass
private void InitializeComponent()
{
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
// listBox1.
this.listBox1.set_Location(new System.Drawing.Point(24,16));
this.listBox1.set_Name("listBox1");
this.listBox1.set_Size(new System.Drawing.Size(576, 277));
this.listBox1.set_TabIndex(0);
// ComponentClass.
this.get_Controls().AddRange(new
System.Windows.Forms.Control[] {this.listBox1 });
this.set_Name("ComponentClass");
this.set_Size(new System.Drawing.Size(624, 320));
this.ResumeLayout(false);
} //InitializeComponent
// This override allows the control to register event handlers for
// IComponentChangeService events
// at the time the control is sited, which happens only in design mode.
/** @property
*/
public ISite get_Site()
{
return super.get_Site();
} //get_Site
/** @property
*/
public void set_Site(ISite value)
{
// Clear any component change event handlers.
ClearChangeNotifications();
// Set the new Site value.
super.set_Site(value);
m_changeService = (IComponentChangeService)
GetService(IComponentChangeService.class.ToType());
// Register event handlers for component change events.
RegisterChangeNotifications();
} //set_Site
private void ClearChangeNotifications()
{
// The m_changeService value is null when not in design mode,
// as the IComponentChangeService is only available at design time.
m_changeService = (IComponentChangeService)
GetService(IComponentChangeService.class.ToType());
// Clear our the component change events to prepare for re-siting.
if (m_changeService != null) {
m_changeService.remove_ComponentChanged(new
ComponentChangedEventHandler(OnComponentChanged));
m_changeService.remove_ComponentChanging(new
ComponentChangingEventHandler(OnComponentChanging));
m_changeService.remove_ComponentAdded(new
ComponentEventHandler(OnComponentAdded));
m_changeService.remove_ComponentAdding(new
ComponentEventHandler(OnComponentAdding));
m_changeService.remove_ComponentRemoved(new
ComponentEventHandler(OnComponentRemoved));
m_changeService.remove_ComponentRemoving(new
ComponentEventHandler(OnComponentRemoving));
m_changeService.remove_ComponentRename(new
ComponentRenameEventHandler(OnComponentRename));
}
} //ClearChangeNotifications
private void RegisterChangeNotifications()
{
// Register the event handlers for the IComponentChangeService events
if (m_changeService != null) {
m_changeService.add_ComponentChanged(new
ComponentChangedEventHandler(OnComponentChanged));
m_changeService.add_ComponentChanging(new
ComponentChangingEventHandler(OnComponentChanging));
m_changeService.add_ComponentAdded(new
ComponentEventHandler(OnComponentAdded));
m_changeService.add_ComponentAdding(new
ComponentEventHandler(OnComponentAdding));
m_changeService.add_ComponentRemoved(new
ComponentEventHandler(OnComponentRemoved));
m_changeService.add_ComponentRemoving(new
ComponentEventHandler(OnComponentRemoving));
m_changeService.add_ComponentRename(new
ComponentRenameEventHandler(OnComponentRename));
}
} //RegisterChangeNotifications
/* This method handles the OnComponentChanged event to
// display a notification.
*/
private void OnComponentChanged(Object sender, ComponentChangedEventArgs ce)
{
if (ce.get_Component() != null &&
((IComponent)ce.get_Component()).get_Site() != null &&
ce.get_Member() != null) {
OnUserChange("The " + ce.get_Member().get_Name()
+ " member of the "
+ ((IComponent)ce.get_Component()).get_Site().get_Name()
+ " component has been changed.");
}
} //OnComponentChanged
/* This method handles the OnComponentChanging event to
display a notification.
*/
private void OnComponentChanging(Object sender,
ComponentChangingEventArgs ce)
{
if (ce.get_Component() != null &&
((IComponent)ce.get_Component()).get_Site() != null &&
ce.get_Member() != null) {
OnUserChange(("The " + ce.get_Member().get_Name()
+ " member of the "
+ ((IComponent)ce.get_Component()).get_Site().get_Name()
+ " component is being changed."));
}
} //OnComponentChanging
/* This method handles the OnComponentAdded event
to display a notification.
*/
private void OnComponentAdded(Object sender, ComponentEventArgs ce)
{
OnUserChange("A component, " + ce.get_Component().get_Site().get_Name()
+ ", has been added.");
} //OnComponentAdded
/* This method handles the OnComponentAdding event
to display a notification.
*/
private void OnComponentAdding(Object sender, ComponentEventArgs ce)
{
OnUserChange("A component of type "
+ ce.get_Component().GetType().get_FullName()
+ " is being added.");
} //OnComponentAdding
/* This method handles the OnComponentRemoved event
to display a notification.
*/
private void OnComponentRemoved(Object sender, ComponentEventArgs ce)
{
OnUserChange("A component, " + ce.get_Component().get_Site().get_Name()
+ ", has been removed.");
} //OnComponentRemoved
/* This method handles the OnComponentRemoving event
to display a notification.
*/
private void OnComponentRemoving(Object sender, ComponentEventArgs ce)
{
OnUserChange("A component, " + ce.get_Component().get_Site().get_Name()
+ ", is being removed.");
} //OnComponentRemoving
/* This method handles the OnComponentRename event
to display a notification.
*/
private void OnComponentRename(Object sender, ComponentRenameEventArgs ce)
{
OnUserChange("A component, " + ce.get_OldName() + ", was renamed to "
+ ce.get_NewName() + ".");
} //OnComponentRename
// This method adds a specified notification message
// to the control's listbox.
private void OnUserChange(String text)
{
listBox1.get_Items().Add(text);
} //OnUserChange
// Clean up any resources being used.
protected void Dispose(boolean disposing)
{
if (disposing) {
ClearChangeNotifications();
if (components != null) {
components.Dispose();
}
}
super.Dispose(disposing);
} //Dispose
} //ComponentClass
플랫폼
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에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Framework
2.0, 1.1, 1.0에서 지원
참고 항목
참조
IComponentChangeService 멤버
System.ComponentModel.Design 네임스페이스
ComponentEventHandler 대리자
ComponentChangedEventHandler 대리자
ComponentChangingEventHandler 대리자
ComponentRenameEventHandler 대리자
MemberDescriptor 클래스
DesignerTransaction 클래스