Associate menu item with type

A

Andrus

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.
 
N

Nathan

Andrus said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top