EditorAttribute 类
本文内容
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定用于更改属性的编辑器。 此类不能被继承。
public ref class EditorAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=true, Inherited=true)]
public sealed class EditorAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=true, Inherited=true)>]
type EditorAttribute = class
inherit Attribute
Public NotInheritable Class EditorAttribute
Inherits Attribute
- 继承
- 属性
下面的代码示例创建 MyImage
类。 类标有 一个 EditorAttribute ,该类指定 ImageEditor 为其编辑器。
[Editor("System.Windows.Forms.ImageEditorIndex, System.Design",
UITypeEditor::typeid)]
public ref class MyImage{
// Insert code here.
};
[Editor("System.Windows.Forms.ImageEditorIndex, System.Design",
typeof(UITypeEditor))]
public class MyImage
{
// Insert code here.
}
<Editor("System.Windows.Forms.ImageEditorIndex, System.Design", _
GetType(UITypeEditor))> _
Public Class MyImage
' Insert code here.
End Class
下面的代码示例创建 类的 MyImage
实例,获取 类的属性,然后打印 所使用的 myNewImage
编辑器的名称。
int main()
{
// Creates a new component.
MyImage^ myNewImage = gcnew MyImage;
// Gets the attributes for the component.
AttributeCollection^ attributes = TypeDescriptor::GetAttributes( myNewImage );
/* Prints the name of the editor by retrieving the EditorAttribute
* from the AttributeCollection. */
EditorAttribute^ myAttribute = dynamic_cast<EditorAttribute^>(attributes[ EditorAttribute::typeid ]);
Console::WriteLine( "The editor for this class is: {0}", myAttribute->EditorTypeName );
return 0;
}
public static int Main() {
// Creates a new component.
MyImage myNewImage = new MyImage();
// Gets the attributes for the component.
AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewImage);
/* Prints the name of the editor by retrieving the EditorAttribute
* from the AttributeCollection. */
EditorAttribute myAttribute = (EditorAttribute)attributes[typeof(EditorAttribute)];
Console.WriteLine("The editor for this class is: " + myAttribute.EditorTypeName);
return 0;
}
Public Shared Sub Main()
' Creates a new component.
Dim myNewImage As New MyImage()
' Gets the attributes for the component.
Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(myNewImage)
' Prints the name of the editor by retrieving the EditorAttribute
' from the AttributeCollection.
Dim myAttribute As EditorAttribute = CType(attributes(GetType(EditorAttribute)), EditorAttribute)
Console.WriteLine(("The editor for this class is: " & myAttribute.EditorTypeName))
End Sub
编辑属性时,可视化设计器应通过对话框或下拉窗口创建指定编辑器的新实例。
EditorBaseTypeName使用 属性查找此编辑器的基类型。 唯一可用的基类型是 UITypeEditor。
EditorTypeName使用 属性获取与此属性关联的编辑器类型的名称。
有关使用特性的一般信息。 请参阅 属性。 有关设计时属性的详细信息,请参阅 特性和 Design-Time 支持。
Editor |
用默认的编辑器(即不使用任何编辑器)初始化 EditorAttribute 类的新实例。 |
Editor |
用编辑器的类型名称和基类型名称初始化 EditorAttribute 类的新实例。 |
Editor |
用类型名和基类型来初始化 EditorAttribute 类的新实例。 |
Editor |
用类型和基类型初始化 EditorAttribute 类的新实例。 |
Editor |
获取作为此编辑器查找键的基类或接口的名称。 |
Editor |
获取 AssemblyQualifiedName 格式的编辑器类的名称。 |
Type |
获取此特性类型的唯一 ID。 |
Equals(Object) |
返回给定对象的值是否等于当前的 EditorAttribute。 |
Get |
返回此实例的哈希代码。 |
Get |
获取当前实例的 Type。 (继承自 Object) |
Is |
在派生类中重写时,指示此实例的值是否是派生类的默认值。 (继承自 Attribute) |
Match(Object) |
当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。 (继承自 Attribute) |
Memberwise |
创建当前 Object 的浅表副本。 (继承自 Object) |
To |
返回表示当前对象的字符串。 (继承自 Object) |
_Attribute. |
将一组名称映射为对应的一组调度标识符。 (继承自 Attribute) |
_Attribute. |
检索对象的类型信息,然后可以使用该信息获取接口的类型信息。 (继承自 Attribute) |
_Attribute. |
检索对象提供的类型信息接口的数量(0 或 1)。 (继承自 Attribute) |
_Attribute. |
提供对某一对象公开的属性和方法的访问。 (继承自 Attribute) |
产品 | 版本 |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |