Creating Dynamic Menu Items

  • Thread starter Stuart Ferguson
  • Start date
S

Stuart Ferguson

Hi All,

I am currently writing an application in C# that uses dynamic menus that are
created from a Database table. The problem I have is that i need a property
in the MenuItem to store the DB Key value when I create the Item (similair
to the Tag property, which is not there). Is there a way of adding the Tag
property to the MenuItem Class, if not is there any property that can store
this data ?

Best Wishes

Stuart Ferguson
 
P

Picho

Stuart,

you can simply creates a new class called... let say - "MyMenuItem" that
inherites "MenuItem" and adds a single object member called "Tag" or even
more members and properties as you like.

code (C#)

using System;
using System.Windows.Forms;

namespace Stuart

public class MyMenuItem : MenuItem
{
private object _tag;

public MyMenuItem() : base()
{
}

public object Tag
{
get
{
return _tag;
}
set
{
_tag = value;
}
}
}
}

Picho
 

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