I have been researching for a couple of days now and to no avail. Does Anyone know how to make a custom collection that take advantage of the collection editor? Code or an actual file would be greatly appreciated. I would like to be able to have 3 Color Values, 1 Boolean and 1 String. If anyone can help me with this, please do.
Collection Editor is That dialog Box that allows you to define stuff in a drop down menu or such. It opens when you click the ... on any value that says (Collection)
How would I go about adding The Items I specified I just Cannot figure it out... I appreciate your time and effort, it is just that I am not Extremely Advanced so, if you can find the time could you make It with the Things I specified? I would greatly Appreciate it.
If you want to customize the CollectionEditor window more, you have to create your own class that derives from CollectionEditor. You can override many methods and properties and customize it the way you like.
vb.net Code:
Public Class CustomColEditor
Inherits CollectionEditor
Public Sub New(ByVal type As Type)
MyBase.New(type)
End Sub
'override properties/methods
End Class
To use, simply set it as the CollectionEditor instead of the base 'CollectionEditor' as in i00's code:
Code:
<Editor(GetType(CustomColEditor), GetType(UITypeEditor))> _
Public Property ...
For a simple example, see my WizardControl (or possibly other controls I created, can't really remember). I needed to use it because I had a collection of Controls, and I needed the editor to create WizardPages, instead of the generic Controls.
There is a method called something like CreateCollectionType (of ItemType, can't remember), which should return the type that the collection editor modifies. If the collection itself is a strongly bound list (List(Of T)) then it should do that automatically, but in my case it was a ControlCollection so it doesn't.
There is also an array variant of that method which allows you to specify multiple types. The 'Add' button then changes into a dropdown button and you can choose one of the types. For an example on that, see my advanced ToolstripContainer control. It can create both ToolStrips and MenuStrips from the same collection editor.
Last edited by NickThissen; Feb 10th, 2010 at 11:53 AM.