My latest pet peeve

Erm, just a thought...but PLEASE...*PLEASE* add a .Tag or .Name property to MenuItem ..i'd be in love then :(
[110 byte] By [codefund.com] at [2007-12-16]
# 1
I agree, this one caused me some pain a while back. I was adding menu items dynamically based on user actions, and had no simple way to tie new menu items to specific data objects. I wound up having to use a Hashtable to look up objects from menu items; that works, but is a real pain to keep up to date and requires some references between objects I'd rather were independent from each other. I considered deriving a class from MenuItem, but I'd have to also create my own main menu component and designer.
codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2
True, but you could design the app using the normal MenuItem class, and then once you're done designing it, search.replace the class name with your own class that includes the Tag property. There was a thread on doing this a while back. -- ken
codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3
aye, i agree with that ken..but that's just a workaround for osmething that you would assume would be common enough to be included. I've implemented an IExtenderProvider in one solution and derived my own MenuItem in another situation...it isnt a big deal, like i said, it's just more of a pet peeve that would be nice to have.
codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 4
I agree. I just read through this group looking for wish list items that are easily fixed with workarounds, in case folks are fighting with stuff. Didn't know your particular context here, but like you said, this is one place if would be useful to have a tag-like property.
codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 5
How much of a hassle would it be move the Tag property from the Control class to the Component class? It shouldn't really be a breaking change as there isn't a tag property on any of the non-visual components (as far as I know). But, maybe there should be...
codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 6
We considered that but the main problem (believe it or not) is instance size. Doing that would require an extra 4-bytes on every component-derived thing in the world which we'd rather not do...it does add up.
codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 7
I solved this by just inheriting from MenuItem and creating my own TaggedMenuItem. Simple stuff, and I only needed a tag on some items generated at runtime anyway.
codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 8
ahhhh...thats true..how about just adding some kind of id or Tag property to the MenuItem object? is this something that's being considered?
codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 9
I've done this before, but then I sacrifice being able to use the designer to modify the menu. Does anyone know if the Menu designer can be forced to use a custom MenuItem instead of the normal framework MenuItem?

Thanks,
Robert W. Grubbs

codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...