Associate menu item with type

  • Thread starter Thread starter Andrus
  • Start date Start date
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.
 
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.
 
Back
Top