By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,168 Members | 1,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,168 IT Pros & Developers. It's quick & easy.

Dynamic Menustrip

P: n/a
Hello,
Why does this code not work? The result is an empty entry in the menu
viewing the debugger I see that the property visible is false. I tried
to make visible=true but it still remains false. And for my
understanding why is an entry with visible=false visible with an empty
string despite the property text is filled well?

public class MyMenuItem : ToolStripItem
{
public MyMenuItem(string Name)
{
this.Name = Name;
}
}

private void AddMenuItems()
{
string[] items = { "MenuItem1", "MenuItem2" };
toolStripMenuItem1.DropDownItems.Clear();

foreach (string item in items)
{
MyMenuItem mmi = new MyMenuItem(item);
mmi.Text = item;
//mmi.Click += new EventHandler(mmi_Click);

toolStripMenuItem1.DropDownItems.Add(mmi);
}
}
Jan 24 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Jürgen Roos wrote:
Hello,
Why does this code not work? The result is an empty entry in the menu
viewing the debugger I see that the property visible is false. I tried
to make visible=true but it still remains false. And for my
understanding why is an entry with visible=false visible with an empty
string despite the property text is filled well?

public class MyMenuItem : ToolStripItem
ToolStripItem is the abstract base class of all the items that can
possibly appear in ToolStrips, and so doesn't have any built in painting
logic. If you want to derive directly from ToolStripItem, it's up to you
to override OnPaint and provide your desired painting behaviour in there
- otherwise (as you have found), nothing gets painted.

If you're happy with, say, the painting of a ToolStripMenuItem, then
just derive from that.
--
Larry Lard
la*******@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Jan 25 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.