当前位置: 首页>>代码示例>>C#>>正文


C# MenuItem构造函数代码示例

本文整理汇总了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";
}
开发者ID:.NET开发者,项目名称:System.Windows.Forms,代码行数:8,代码来源:MenuItem

示例2: CreateMyMenus

public void CreateMyMenus()
{
   // Create an instance of a MenuItem with a specified caption.
   menuItem1 = new MenuItem("&File");
}
开发者ID:.NET开发者,项目名称:System.Windows.Forms,代码行数:5,代码来源:MenuItem

示例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.
}
开发者ID:.NET开发者,项目名称:System.Windows.Forms,代码行数:11,代码来源:MenuItem

示例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);
}
开发者ID:.NET开发者,项目名称:System.Windows.Forms,代码行数:16,代码来源:MenuItem

示例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.
}
开发者ID:.NET开发者,项目名称:System.Windows.Forms,代码行数:14,代码来源:MenuItem

示例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.
}
开发者ID:.NET开发者,项目名称:System.Windows.Forms,代码行数:41,代码来源:MenuItem


注:本文中的System.Windows.Forms.MenuItem.MenuItem构造函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。