471,350 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Associate menu item with type

In WinForms Menu designer I need to associate type with menu item.
In properties window for Customer menu item I entered

=typeof(Customer)

but designer creates code

this.customerToolStripMenuItem.Tag = "=typeof(Customer)";

How to force it to create

this.customerToolStripMenuItem.Tag = typeof(Customer);
Andrus.

Jun 27 '08 #1
1 866
"Andrus" <ko********@hot.eewrote in message
news:ep*************@TK2MSFTNGP05.phx.gbl...
In WinForms Menu designer I need to associate type with menu item.
In properties window for Customer menu item I entered
=typeof(Customer)

but designer creates code

this.customerToolStripMenuItem.Tag = "=typeof(Customer)";

How to force it to create

this.customerToolStripMenuItem.Tag = typeof(Customer);
Andrus.
The "Tag" property stores an instance of an "Object." A System.Type does
not inherit System.Object, so a type cannot be stored in Tag. You'd have to
find some sort of work-around such as storing the type's name
(typeof(Customer).ToString()), or maybe an integer representing a value in
an enumeration that contains all the Types that might be assigned to a
menu's tag. Of course, what you're doing with the Tag on menu_Click will
determine what is stored in the tag.

Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jackson Yap | last post: by
3 posts views Thread by unurban | last post: by
6 posts views Thread by Ashok | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.