本文整理汇总了C#中System.Windows.Forms.MenuItem.MenuItem构造函数的典型用法代码示例。如果您正苦于以下问题:C# MenuItem构造函数的具体用法?C# MenuItem怎么用?C# MenuItem使用的例子?那么, 这里精选的构造函数代码示例或许可以为您提供帮助。您也可以进一步了解该构造函数所在类System.Windows.Forms.MenuItem
的用法示例。
在下文中一共展示了MenuItem构造函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMyMenu
public void CreateMyMenu()
{
// Create an empty menu item object.
MenuItem menuItem1 = new MenuItem();
// Intialize the menu item using the parameterless version of the constructor.
// Set the caption of the menu item.
menuItem1.Text = "&File";
}
示例2: CreateMyMenus
public void CreateMyMenus()
{
// Create an instance of a MenuItem with a specified caption.
menuItem1 = new MenuItem("&File");
}
示例3: CreateMyMenuItem
public void CreateMyMenuItem()
{
// Create an instance of MenuItem with caption and an event handler
MenuItem menuItem1 = new MenuItem("&New", new System.EventHandler(this.MenuItem1_Click));
}
// This method is an event handler for menuItem1 to use when connecting its event handler.
private void MenuItem1_Click(Object sender, System.EventArgs e)
{
// Code goes here that handles the Click event.
}
示例4: CreateMyMenuItem
public void CreateMyMenuItem()
{
// submenu item array.
MenuItem[] subMenus = new MenuItem[3];
// Create three menu items to add to the submenu item array.
MenuItem subMenuItem1 = new MenuItem("Red");
MenuItem subMenuItem2 = new MenuItem("Blue");
MenuItem subMenuItem3 = new MenuItem("Green");
// Add the submenu items to the array.
subMenus[0] = subMenuItem1;
subMenus[1] = subMenuItem2;
subMenus[2] = subMenuItem3;
// Create an instance of a MenuItem with caption and an array of submenu
// items specified.
MenuItem MenuItem1 = new MenuItem("&Colors", subMenus);
}
示例5: CreateMyMenuItem
public void CreateMyMenuItem()
{
// Create a MenuItem with caption, shortcut key, and an event handler
// specified.
MenuItem MenuItem1 = new MenuItem("&New",
new System.EventHandler(this.MenuItem1_Click), Shortcut.CtrlL);
}
// The following method is an event handler for menuItem1 to use when
// connecting the event handler.
private void MenuItem1_Click(Object sender, EventArgs e)
{
// Code goes here that handles the Click event.
}
示例6: CreateMyMenuItem
public void CreateMyMenuItem()
{
// Submenu item array.
MenuItem[] subMenus = new MenuItem[3];
// Create three menu items to add to the submenu item array.
MenuItem subMenuItem1 = new MenuItem("Red");
MenuItem subMenuItem2 = new MenuItem("Blue");
MenuItem subMenuItem3 = new MenuItem("Green");
// Add the submenu items to the array.
subMenus[0] = subMenuItem1;
subMenus[1] = subMenuItem2;
subMenus[2] = subMenuItem3;
/* Create a MenuItem with caption, shortcut key,
a Click, Popup, and Select event handler, merge type and order, and an
array of submenu items specified.
*/
MenuItem menuItem1 = new MenuItem(MenuMerge.Add, 0,
Shortcut.CtrlShiftC, "&Colors",
new EventHandler(this.MenuItem1_Click),
new EventHandler(this.MenuItem1_Popup),
new EventHandler(this.MenuItem1_Select), subMenus);
}
// The following method is an event handler for menuItem1 to use when connecting the Click event.
private void MenuItem1_Click(Object sender, EventArgs e)
{
// Code goes here that handles the Click event.
}
// The following method is an event handler for menuItem1 to use when connecting the Popup event.
private void MenuItem1_Popup(Object sender, EventArgs e)
{
// Code goes here that handles the Click event.
}
// The following method is an event handler for menuItem1 to use when connecting the Select event
private void MenuItem1_Select(Object sender, EventArgs e)
{
// Code goes here that handles the Click event.
}