ComponentChangingEventArgs 类

ComponentChanging 事件提供数据。无法继承此类。

**命名空间:**System.ComponentModel.Design
**程序集:**System(在 system.dll 中)

语法

声明
<ComVisibleAttribute(True)> _
Public NotInheritable Class ComponentChangingEventArgs
    Inherits EventArgs
用法
Dim instance As ComponentChangingEventArgs
[ComVisibleAttribute(true)] 
public sealed class ComponentChangingEventArgs : EventArgs
[ComVisibleAttribute(true)] 
public ref class ComponentChangingEventArgs sealed : public EventArgs
/** @attribute ComVisibleAttribute(true) */ 
public final class ComponentChangingEventArgs extends EventArgs
ComVisibleAttribute(true) 
public final class ComponentChangingEventArgs extends EventArgs

备注

ComponentChangingEventArgs 提供有关 ComponentChanging 事件的数据。ComponentChanging 事件向 IComponentChangeService 和注册的事件处理程序通知,当前处于活动状态的设计文档中的特定组件将要发生更改。此事件提供了一种可广泛访问的方法,用以防止组件发生更改。

ComponentChanging 事件在更改组件前引发。此事件为设计器提供了中止更改的机会。组件设计器通常会自动引发 ComponentChanging 事件。如果无法更改某一属性,则处理该事件的方法就可能引发异常。例如,如果将设计器文件签入源代码管理,则此事件的处理程序通常会在用户拒绝签出文件时引发异常。

ComponentChangingEventArgs 提供下列信息:

  • 指示将要修改的组件的 Component 属性。

  • 指示将要更改的成员的 Member 属性。

提示

应用于此类的 HostProtectionAttribute 属性 (Attribute) 具有以下 Resources 属性 (Property) 值:SharedStateHostProtectionAttribute 不影响桌面应用程序(桌面应用程序一般通过双击图标,键入命令或在浏览器中输入 URL 启动)。有关更多信息,请参见 HostProtectionAttribute 类或 SQL Server 编程和宿主保护属性

给继承者的说明 如果将此类指定为另一个类的基类,则发生编译器错误。

示例

下面的示例说明如何创建 ComponentChangingEventArgs

' This example method creates a ComponentChangingEventArgs using the specified arguments.
' Typically, this type of event args is created by a design mode subsystem.  
Public Function CreateComponentChangingEventArgs(ByVal component As Object, ByVal member As MemberDescriptor) As ComponentChangingEventArgs
    Dim args As New ComponentChangingEventArgs(component, member)

    ' The component that is about to change:       args.Component
    ' The member that is about to change:          args.Member

    Return args
End Function
// This example method creates a ComponentChangingEventArgs using the specified arguments.
// Typically, this type of event args is created by a design mode subsystem.  
public ComponentChangingEventArgs CreateComponentChangingEventArgs(object component, MemberDescriptor member)
{
    ComponentChangingEventArgs args = new ComponentChangingEventArgs(component, member);

    // The component that is about to change:       args.Component
    // The member that is about to change:          args.Member

    return args;
}
public:
   // This example method creates a ComponentChangingEventArgs using the specified arguments.
   // Typically, this type of event args is created by a design mode subsystem.
   ComponentChangingEventArgs^ CreateComponentChangingEventArgs( Object^ component, MemberDescriptor^ member )
   {
      // The component that is about to change:       args.Component
      // The member that is about to change:          args.Member
      return gcnew ComponentChangingEventArgs( component,member );
   }
// This example method creates a ComponentChangingEventArgs
// using the specified arguments.
// Typically, this type of event args is created by a design mode subsystem.
public ComponentChangingEventArgs CreateComponentChangingEventArgs(
    Object component, MemberDescriptor member)
{
    ComponentChangingEventArgs args = new 
        ComponentChangingEventArgs(component, member);
    // The component that is about to change:       args.Component
    // The member that is about to change:          args.Member
    return args;
} //CreateComponentChangingEventArgs

继承层次结构

System.Object
   System.EventArgs
    System.ComponentModel.Design.ComponentChangingEventArgs

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

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

请参见

参考

ComponentChangingEventArgs 成员
System.ComponentModel.Design 命名空间
ComponentChanging
ComponentChanged
ComponentChangingEventHandler
IComponentChangeService