473,513 Members | 3,208 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic Menustrip

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
1 3696
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5475
by: Alvo von Cossel I | last post by:
hi, i have a modern looking application without the cotrolbox-bar because i've created my own. i have a restore down button with an image that has a grey background. if the user has a different...
0
1835
by: rellik | last post by:
Hi All, I've run into a problem with the MenuStrip control and any help would be greatly appreciated! The problem I've got is that when use a control derived from the MenuStrip class all MDI...
0
2353
by: academic | last post by:
Using ToolStripManager.Merge(ToolStrip,ToolStrip) I've been able to merge a MenuStrip into a MenuStrip but never a ContextMenuStrip into a MenuStrip. From the docs it seems to me I should be...
0
1644
by: Chris Peeters | last post by:
Hi, I have an MDI-application running with 1 MDI chilld showing in 'Normal'-WindowState, so NOT maximized. What I see is the MDI-main window showing its title bar, below that the menustrip with...
1
4029
by: Schwammkopf | last post by:
Hi ! I'm using Visual Studio 2005 Professional Edition and C#. I have a simple question: I want to add to my form, which is a scrollable control, a menustrip and statusstrip. The problem is...
0
1685
by: active | last post by:
For the last 3 or 4 days I've been, on an off, searching the Internet and theVS2005 Doc for an example of how to add a contextmenustrip to a menustrip. I can move all the items from a...
3
2731
by: Gav | last post by:
I am using a MenuStrip on a form and adding a Panel to the same form in the program. When the Panel is added the top of the Panel is behind the MenuStrip, so the top of the Panel is hidden. How do...
0
5022
by: kyungdongkim | last post by:
Hi, I have a dynamically generated MenuStrip following this example: http://www.codeproject.com/useritems/Dynamic_MenuStrip.asp Basically the menu strip allows users to save and load reports. ...
3
6556
by: ssknov | last post by:
hi i am creating a login page.Inthe form load itself i need to hide the MenuStrip in MDI Parent to HIDE, When the users gives the correct passwd and pushes the Loginbutton , My MDIParent1 forms...
1
2353
by: Alexander Vasilevsky | last post by:
How placing text in MenuStrip, glued it to the right side MenuStrip? http://www.alvas.net - Audio tools for C# and VB.Net developers + Christmas discount
0
7254
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.