Hi Jacek,
First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to add extra information
to a menuitem by using Tag Property which the menutiem does no have.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.
I think we can create a new class derived from MenuItem and add a Tag
proterty to the class.
public class MyMenuItem : MenuItem
{
object _Tag;
public object Tag
{
get
{
return _Tag;
}
set
{
_Tag = value;
}
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
MainMenu menu = new MainMenu();
this.Menu= menu;
MyMenuItem menuItem1 = new MyMenuItem();
menuItem1.Text="hello";
menuItem1.Tag="fsdf";
menuItem1.Click+=new EventHandler(menuItem1_Click);
menu.MenuItems.Add(menuItem1);
}
private void menuItem1_Click(object sender, EventArgs e)
{
MessageBox.Show("menuItem1.Tag: " + (this.Menu.MenuItems[0] as
MyMenuItem).Tag.ToString());
}
Please apply my suggestion above and let me know if it helps resolve your
problem.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.