The following code example creates the MyImage class. The class is marked with an EditorAttribute that specifies the ImageEditor as its editor.
|
<Editor("System.Windows.Forms.ImageEditorIndex, System.Design", _
GetType(UITypeEditor))> _
Public Class MyImage
' Insert code here.
End Class 'MyImage
|
|
[Editor("System.Windows.Forms.ImageEditorIndex, System.Design",
typeof(UITypeEditor))]
public class MyImage
{
// Insert code here.
}
|
|
[Editor("System.Windows.Forms.ImageEditorIndex, System.Design",
UITypeEditor::typeid)]
public ref class MyImage{
// Insert code here.
};
|
|
/** @attribute Editor("System.Windows.Forms.ImageEditorIndex, "
+ "System.Design", UITypeEditor.class)
*/
public static class MyImage
{
// Insert code here.
} //MyImage
|
The following code example creates an instance of the MyImage class, gets the attributes for the class, and then prints the name of the editor used by myNewImage.
|
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 'Main
|
|
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;
}
|
|
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 void main(String[] args)
{
// 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.get_Item(EditorAttribute.class.ToType()));
Console.WriteLine("The editor for this class is: "
+ myAttribute.get_EditorTypeName());
} //main
|