5,427,813 members and growing! (17,224 online)
Email Password   helpLost your password?
Desktop Development » Menus » Toolbars     Intermediate

Magic MenuControl - VS.NET Style

By Phil Wright

Menus that mimic VS.NET/OfficeXP
C#, Windows, .NET 1.0, .NETVisual Studio, VS.NET2002, Dev

Posted: 29 Sep 2002
Updated: 29 Sep 2002
Views: 235,045
Bookmarked: 86 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
52 votes for this Article.
Popularity: 7.43 Rating: 4.33 out of 5
5 votes, 11.6%
1
0 votes, 0.0%
2
2 votes, 4.7%
3
3 votes, 7.0%
4
33 votes, 76.7%
5

Sample Image - MagicMenuControl.gif

Why another MenuControl?

The .NET Framework contains a wide range of user interface controls, but they offer only a basic look and feel. Today's user expects a richer experience that you just cannot build with the out-of-the-box controls. The Magic Library (of which this MenuControl is a major part) aims to solve this by providing a set of user interface elements that add the sophistication expected from modern Windows applications.

Downloads

The first download MenuControl Sample contains a example application that uses shows the MenuControl from the Magic Library. This allows you to experiment and test out the feature. The actual source code is inside the separate second download. At nearly 1MB in size, I thought people would prefer to download the sample before deciding if they want to install the entire source code project!

Description

The usual way to create a menu for your application is via the Menu property of your applications main Form. Unfortunately this gives a very basic look and feel and does not support the new Visual Studio .NET appearance.

This is where the MenuControl class comes into its own as it closely mimics the Visual Studio .NET look and feel. Not only that, but you can create as many instances as you like and place them anywhere on your Form. You can even use the Dock property to place the control against the left/right and bottom edges as well as the traditional top position. When placed on the left or right edges it will draw the menu items vertically.

When using the control within an MDI application it is important that exactly one instance of the MenuControl uses the MdiContainer property. This property should be given a reference to the MDI parent Form so that it can correctly display the pendant for MDI child Forms .

MenuCommand Instances

The control exposes a property called MenuCommands that contains the collection of MenuCommand instances for display. You cannot use the builtin menu designer to generate the instances and so will need to use code to create the structure you need. Look at the sample code to see how this is done.

PopupMenu

Also demonstrated in the sample is use of the PopupMenu class that can be seen by right clicking the RichTextBox present inside each MDI child instance. This shows how to create a context menu using the VS.NET/OfficeXP look and feel. It uses the same MenuCommand instances as the MenuControl.

More Details

Download and install the Magic Libary where a couple of more detailed artiles describe how all the various features of the MenuControl and PopupMenu work.

Revision History

30 Sept 2002 - Initial Revision

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Phil Wright


I am a big fan of .NET and have been working on developing a free user interface library to enhance the very basic controls that come out-of-the-box. Download the free source code project from http://www.dotnetmagic.com. I often carry out bespoke development work for companies, so feel free to email me for a quote on your .NET needs!



Occupation: Web Developer
Location: United Kingdom United Kingdom

Other popular Menus articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 60 (Total in Forum: 60) (Refresh)FirstPrevNext
Subject  Author Date 
QuestionlicxmemberHemantPune20:32 16 Sep '07  
GeneralNow it is no more for freesussAnonymous6:57 7 Jun '05  
GeneralRe: Now it is no more for freememberGazon8:54 7 Jun '05  
GeneralDon't add the MDI child Menumembercscrazy3:49 14 May '05  
GeneralRelate with NotifyIconmemberGazon17:30 12 Feb '05  
GeneralProgrammatically forcing an update?memberRick Pingry10:24 21 Dec '04  
GeneralNot CLS Compliant?memberRick Pingry14:45 8 Sep '04  
GeneralRe: Not CLS Compliant?memberDelphiCoder20:49 12 Oct '04  
GeneralRe: Not CLS Compliant?memberRick Pingry5:08 13 Oct '04  
GeneralRe: Not CLS Compliant?memberDelphiCoder10:43 20 Oct '04  
GeneralRe: Not CLS Compliant?memberRick Pingry11:11 20 Oct '04  
GeneralNedd GUI controlsmembersend2tusharp@yahoo.com21:11 29 Aug '04  
GeneralProblems with dynamic contextmenu + notifyIconmembergein1:31 29 May '04  
GeneralProgrammatically opening a menumemberRick Pingry7:35 25 May '04  
GeneralHow I Install DotNetBar in my Visual Studio .NETmembersk0rpi0n5:44 16 Mar '04  
GeneralError with menu within menumemberKlaasjanMors12:17 14 Feb '04  
GeneralMerge MDI Child Menu with MDI Parent Menu.memberSunilNRao19:58 11 Jan '04  
GeneralAdding "Popup Menu" as Context Menu to a ToolBarmemberjayakarthikeyan4:10 23 Dec '03  
GeneralCompiling on command linememberMarc Heiligers8:04 5 Nov '03  
GeneralBUG: Showing a PopupMenu over controls that handle MouseEnter/MouseLeavememberdacris10:17 27 Aug '03  
GeneralRe: BUG: Showing a PopupMenu over controls that handle MouseEnter/MouseLeavesussAnonymous10:05 4 Oct '04  
GeneralTo Philmembernamortaror@hotmail.com6:50 20 Aug '03  
GeneralUrgent!memberpsusong2:17 18 Jun '03  
GeneralSos!!How can i add my own icon to the menu??sussAnonymous2:24 8 Apr '03  
GeneralRe: Sos!!How can i add my own icon to the menu??memberManster4:19 7 Jul '03  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 29 Sep 2002
Editor: Chris Maunder
Copyright 2002 by Phil Wright
Everything else Copyright © CodeProject, 1999-2008
Web10 | Advertise on the Code Project