This answer applies to VB.NET. I plan on turning this into C# for a DLL, but for now it's in vb.net because that's where I started this idea from and the language the project is in.
Here's what I have so far:
ToolStripMenuItemExt
Purpose: My custom ToolStripMenuItem
.
ToolStripMenuItemExt
has a CheckListSheet
which contains a reference to ToolStripMenuItemExt
's DropDownItems (I passed in dropdownitems byref and not byval). It has one property that returns the CheckLists
object in CheckListSheet
.
CheckListSheet
Purpose: Maintains a reference to the collection I'm observing through an observable collection type and an object of the collection I return in ToolStripMenuItemExt
.
CheckListSheet
has the CheckLists
object. The dropdownitems I pass in byref are stored in an ObservableToolStripItemCollection
which hopefully when I get to testing it allows me to update the collection of checklists easier since it inherits ObservableCollection(of ToolStripItemCollection)
. This class also has a shared function that returns the observable collection which has a scope identifier of private shared.
CheckLists
Purpose: The CollectionBase
type that stores CheckList
objects.
CheckList
Purpose: Stores the ToolStripItemCollection
whose objects act as a single item checked checklist (only one item is checked at a time).
This has some properties for the designer and the collection for the check list. Eventually I'll add in the logic to check and automatically uncheck and raise an event for it.
MenuItemCheckListCollectionEditor
Purpose: Allows a collection of known and instantiated ToolStripItem
objects to be displayed and added to a CheckList
.
Right now it demands I give it a Type or array of Types so it can establish itself what type of CollectionEditor
it is. I haven't be able to show a drop down of types or a drop down of ToolStripItem
objects. Any class having ToolStrip in their name inherits ToolStripItem which is why I use this type of object.
If ANYONE has any advice on my current answer or can forecast any foreseeable pitfalls please share. I don't care if you talk in c# or vb.net. Maybe I just need to stop and turn this into c# code. Maybe this is impossible. I am making progress though. What would be extremely helpful is figuring out how MenuStrip's collection editor is able to populate a dropdown of ToolStripItems
[Update]
A collection Editor requires you to provide a type for it to display. This type has to inherit CollectionBase
which means at design time there's no way for it to reference the dropdownitems. :sigh: