Help Menu : MenuItem « GUI Windows Form « C# / C Sharp






Help Menu

 
using System;
using System.Drawing;
using System.Windows.Forms;
   
class HelpMenu: Form
{
     Bitmap bmHelp;
   
     public static void Main()
     {
          Application.Run(new HelpMenu());
     }
     public HelpMenu()
     {
          bmHelp = new Bitmap(GetType(), "help.bmp");
   
          Menu = new MainMenu();
          Menu.MenuItems.Add("&Help");
   
          MenuItem mi     = new MenuItem("&Help");
          mi.OwnerDraw    = true;
          mi.Click       += new EventHandler(MenuHelpOnClick);
          mi.DrawItem    += new DrawItemEventHandler(MenuHelpOnDrawItem);
          mi.MeasureItem += new MeasureItemEventHandler(MenuHelpOnMeasureItem);
   
          Menu.MenuItems[0].MenuItems.Add(mi);
     }
     void MenuHelpOnMeasureItem(object obj, MeasureItemEventArgs miea)
     {
          miea.ItemWidth  = bmHelp.Width;
          miea.ItemHeight = bmHelp.Height;
     }
     void MenuHelpOnDrawItem(object obj, DrawItemEventArgs diea)
     {
          Rectangle rect = diea.Bounds;
          rect.X += diea.Bounds.Width - bmHelp.Width;
          rect.Width = bmHelp.Width;
   
          diea.DrawBackground();
          diea.Graphics.DrawImage(bmHelp, rect);
     }
     void MenuHelpOnClick(object obj, EventArgs ea)
     {
          MessageBox.Show("Help", Text);
     }
}

 








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.Add Help text for MenuItem