Hi
I've a question about the System.ComponentModel.EditorAttribute...
I am currently using it to decorate a property within a class in my object model so that it will open with a custom UITypeEditor in a propertygrid.
Public Class MyDataClass
<Editor(GetType(MyCustomUITypeEditor ),GetType(UITypeEditor))> _
Public Property MyProperty
...
End Property
End Class
Public Class MyCustomUITypeEditor
Inherits UITypeEditor
' overridemethods as necessary to show a custom editing dialog
...
End Class
Public Class MyUIClass
PrivatemyDataObjectas new MyDataClass
Private myPropertyGrid as new PropertyGrid()
...
Public Sub EditInstance()
myPropertyGrid.SelectedObject = myDataObject
myPropertyGrid.visible = true
' and away editing we go...
End Sub
End Class
Now this works fine except that I actually want to write MyUIClass and MyCustomEditorin another assembly not referenced by my data model, but I can't do this as MyClass requires a reference to MyCustomEditor (which in turn requires a reference to MyUIClass). However good design dictates I shouldn't have a reference to myview/controller in my model classes and besides, I might also want to specify more than one UITypeEditor if I had more than one UI to edit this property - which can't be done with an attribute.
Iit possible to do something like the following?
Public Class MyUIClass
...
Public Sub EditInstance()
Dim myEditorAttribute as New EditorAtribute(GetType(MyCustomUITypeEditor ),GetType(UITypeEditor))
' need some reflection jiggery pokery here to attach the attribute - don't think this can be done...
myDataObject.Properties("MyProperty").Attributes.Add(myEditorAttribute)
myPropertyGrid.SelectedObject = myObject
myPropertyGrid.visible = true
' and away editing we go...
End Sub
End Class
If not by extending the attributes of the property at runtime, which I would presume to be impossible, is there some other way ofdoing this imperatively that I've missed?
Many thanks
Iain Mcleod