Name property in MainMenu/MenuItem

  • Thread starter Trevor Benedict R
  • Start date
T

Trevor Benedict R

What I am trying to do is to store some sort of a Reference to the Menu in
the database and then based on permission I can either Enable or disable
them. I am specifically looking for the Name/ID/Tag property, but
unforturnately could not find one for the Mainmenu or Menuitem.

Any ideas.

TIA

Trevor Benedict
 
S

simida

Maybe you can extend MenuItem and add your custom property to subclass
that inherits MenuItem, such as ,Tag.

Now , you can add your subclass to Mainmenu.MenuItems container. Hope
it works.

Sincerely,
simida

Trevor Benedict R 写é“:
 
T

Trevor Benedict R

Thanks. I have already done that, but do not know how to tell the inherited
control from MainMenu to use my MenuItem instead of the one from
windows.forms.menuitem.

Regards,

Trevor Benedict

Maybe you can extend MenuItem and add your custom property to subclass
that inherits MenuItem, such as ,Tag.

Now , you can add your subclass to Mainmenu.MenuItems container. Hope
it works.

Sincerely,
simida

Trevor Benedict R ??:
 
G

Guest

Trevor Benedict R said:
Thanks. I have already done that, but do not know how to tell the inherited
control from MainMenu to use my MenuItem instead of the one from
windows.forms.menuitem.

If you've defined your custom menu item as follows:

public class MyMenuItem : MenuItem { ... }

Then in your inherited control, you can do this:

void ProcessMenuItem( MenuItem item )
{
MyMenuItem myItem = item as MyMenuItem;
if (myItem != null)
{
// process item
}
}
 
T

Trevor Benedict R

Thanks Timm,
But what I am looking at it to add some Custom Properties to the MenuItem
Class, by Inheriting it. I then need a way to use this Custom Menu Item
Class to be used by the MainMenu Control while being used in the Design
Mode.

What I have done is to Inherit the MenuItem and I have changed the Designer
Generated Code to Change all references to System.Windows.Forms.MenuItem to
MyProject.MyMenuItem, we'll the downside is that I will leave behind a very
poor design for other developers who might take over this project.

I was wondering if I could somehow Inherit the MainMenu Class and then tell
it to use myMenuItem. Hope I was clear enough.

I've also tried a different approach by using IExtenderProvider, I'm still
working on it.

Regards,

Trevor Benedict R
 

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