Add Help text for MenuItem : MenuItem « GUI Windows Form « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » GUI Windows Form » MenuItemScreenshots 
Add Help text for MenuItem
 
using System;
using System.Drawing;
using System.Windows.Forms;
   
class MenuItemHelp: MenuItem
{
     StatusBarPanel sbpHelpPanel;
     string         strHelpText;

     public MenuItemHelp(string strText): base(strText)
     {
     }
     public StatusBarPanel HelpPanel
     {
          get return sbpHelpPanel; }
          set sbpHelpPanel = value; }
     }
     public string HelpText
     {
          get return strHelpText; }
          set strHelpText = value; }
     }
     protected override void OnSelect(EventArgs ea)
     {
          base.OnSelect(ea);
   
          if (HelpPanel != null)
               HelpPanel.Text = HelpText;
     }
}


class MenuHelpSubclass: Form
{
     StatusBarPanel sbpMenuHelp;
     string         strSavePanelText;
   
     public static void Main()
     {
          Application.Run(new MenuHelpSubclass());
     }
     public MenuHelpSubclass()
     {

          StatusBar sb = new StatusBar();
          sb.Parent = this;
          sb.ShowPanels = true;
   
          sbpMenuHelp = new StatusBarPanel();
          sbpMenuHelp.Text = "Ready";
          sbpMenuHelp.AutoSize = StatusBarPanelAutoSize.Spring;
   
          sb.Panels.Add(sbpMenuHelp);
   
          Menu = new MainMenu();
          
          MenuItemHelp mi = new MenuItemHelp("&File");
          mi.HelpPanel = sbpMenuHelp;
          mi.HelpText = "Commands for working with files";
          Menu.MenuItems.Add(mi);
   
          mi = new MenuItemHelp("&Open...");
          mi.HelpPanel = sbpMenuHelp;
          mi.HelpText = "Opens an existing document";
          Menu.MenuItems[0].MenuItems.Add(mi);
          
          mi = new MenuItemHelp("&Close");
          mi.HelpPanel = sbpMenuHelp;
          mi.HelpText = "Closes the current document";
          Menu.MenuItems[0].MenuItems.Add(mi);
   
          mi = new MenuItemHelp("&Save");
          mi.HelpPanel = sbpMenuHelp;
          mi.HelpText = "Saves the current document";
          Menu.MenuItems[0].MenuItems.Add(mi);
   
          mi = new MenuItemHelp("&Edit");
          mi.HelpPanel = sbpMenuHelp;
          mi.HelpText = "Commands for editing the document";
          Menu.MenuItems.Add(mi);
   
          mi = new MenuItemHelp("Cu&t");
          mi.HelpPanel = sbpMenuHelp;
          mi.HelpText = "Deletes the selection and " +
                        "copies it to the clipboard";
          Menu.MenuItems[1].MenuItems.Add(mi);
          
          mi = new MenuItemHelp("&Copy");
          mi.HelpPanel = sbpMenuHelp;
          mi.HelpText = "Copies the selection to the clipboard";
          Menu.MenuItems[1].MenuItems.Add(mi);
   
          mi = new MenuItemHelp("&Paste");
          mi.HelpPanel = sbpMenuHelp;
          mi.HelpText = "Replaces the current selection " +
                        "with the clipboard contents";
          Menu.MenuItems[1].MenuItems.Add(mi);
     }
     protected override void OnMenuStart(EventArgs ea)
     {
          strSavePanelText = sbpMenuHelp.Text;
     }
     protected override void OnMenuComplete(EventArgs ea)
     {
          sbpMenuHelp.Text = strSavePanelText;
     }
}

 
Related examples in the same category
1.new MenuItem
2.Creating a menu on the fly.
3.Set MenuItem ShortCut
4.Font Menu
5.Subclass MenuItem
6.RadioCheck MenuItem
7.Hatch Brush Menu
8.Owner Drawn Menu ControlOwner Drawn Menu Control
9.Owner Drawn MenuOwner Drawn Menu
10.Help Menu
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.