September 9, 2002 - Hierarchy Levels of Menus | WebReference

September 9, 2002 - Hierarchy Levels of Menus

Yehuda Shiran September 9, 2002
Hierarchy Levels of Menus
Tips: September 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

You can use JScript .NET to add menu bars to a Windows form. Suppose we want to add the File menu at the top menu bar, as you find in most applications. Let's further assume that we want to include a single item in this File menu, the Save entry. In addition, we want to have a shortcut key for this entry, which is CTRL-S, as in most Windows applications.

Windows forms support two relevant classes for menu building: MainMenu and MenuItem. A menu item in Windows forms needs three variables:

File in our case)
  • The menu item (
  • Save in our case)

    Let's call these variables menuMain, menuFile, and menuSave. We define them as follows:

      var menuMain : System.Windows.Forms.MainMenu;
      var menuFile : System.Windows.Forms.MenuItem; 
      var menuSave : System.Windows.Forms.MenuItem;
    To learn more about JScript .NET and ASP.NET, go to Column 117, JScript .NET, Part XI: Creating Windows Forms.