C# School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C# Expert!

Join 307,153 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,655 people online right now. Registration is fast and FREE... Join Now!




MenuStrip

 

MenuStrip

jammmie999

16 Aug, 2009 - 01:55 AM
Post #1

New D.I.C Head
*

Joined: 1 Apr, 2009
Posts: 39


My Contributions
Hi guys

In my designer my menuStrip looks really boring like this
IPB Image
How can I give it a style/theme to make it look like this (from notepad)
IPB Image

Thanks guys


User is offlineProfile CardPM
+Quote Post

 
Reply to this topicStart new topic
Replies(1 - 4)

Core

RE: MenuStrip

16 Aug, 2009 - 02:05 AM
Post #2

The .NET Dude
Group Icon

Joined: 8 Dec, 2008
Posts: 3,041



Thanked: 217 times
Dream Kudos: 900
Expert In: C#, VB.NET, WPF, .NET Framework

My Contributions
You cannot use this style by default, but you can create it programatically. Instead of using the MenuStrip control, in the Form_Load event use the MainMenu class, add several items and assign it to the Menu property of the main form. Something that will look like this:

CODE

            MainMenu menu = new MainMenu();
            menu.MenuItems.Add("AAA");
            this.Menu = menu;

User is online!Profile CardPM
+Quote Post

jammmie999

RE: MenuStrip

16 Aug, 2009 - 02:20 AM
Post #3

New D.I.C Head
*

Joined: 1 Apr, 2009
Posts: 39


My Contributions
Thank you.

For anyone else reading this Click here For more information regarding the MainMenu.

Does anyone know how to add a splitter/seperator in this menu?

Thanks again.

This post has been edited by jammmie999: 16 Aug, 2009 - 03:03 AM
User is offlineProfile CardPM
+Quote Post

Core

RE: MenuStrip

16 Aug, 2009 - 02:32 AM
Post #4

The .NET Dude
Group Icon

Joined: 8 Dec, 2008
Posts: 3,041



Thanked: 217 times
Dream Kudos: 900
Expert In: C#, VB.NET, WPF, .NET Framework

My Contributions
Take a look at the documentation on MainMenu class. You will have to operate with the MenuItem class to add actual items and sub-items.

You need this:

CODE

            MenuItem item = new MenuItem("Item");
            MenuItem subItem = new MenuItem("SubItem");
            item.MenuItems.Add(subItem);

            // Adds the event handler for the subitem
            subItem.Click += new EventHandler(subItem_Click);

            MainMenu menu = new MainMenu();
            menu.MenuItems.Add(item);
            this.Menu = menu;


As you see, I included a reference for an event handler. That will look like this:

CODE

        void subItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("This works!");
        }

User is online!Profile CardPM
+Quote Post

jammmie999

RE: MenuStrip

16 Aug, 2009 - 05:48 AM
Post #5

New D.I.C Head
*

Joined: 1 Apr, 2009
Posts: 39


My Contributions
Thanks

I have got the seperator now.
For anyone else that want's to know to create a seperator use
CODE

MenuItem subItem = new MenuItem("-");
item.MenuItems.Add(subItem);

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 05:07PM

Live C# Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month