C#中怎样在ToolStripMenuItem下再添加子级菜单
2021-01-22 05:13
标签:down ext 构建 关系 新建 span 对象 博客 eset 在右键菜单ContextMenuStrip下添加子菜单选项可以通过 来实现。但是如果在右键菜单的子菜单选项下再添加子菜单选项,形成二级子菜单。 注: 博客主页: ToolStripMenuItem 的子级菜单仍然是ToolStripMenuItem
,主要通过DropDownItems属性来构建关联关系。 构建右键二级子菜单示例代码 C#中怎样在ToolStripMenuItem下再添加子级菜单 标签:down ext 构建 关系 新建 span 对象 博客 eset 原文地址:https://www.cnblogs.com/badaoliumangqizhi/p/12089588.html场景
ContextMenuStrip menuStrip
ToolStripMenuItem mnuChartOption = new ToolStripMenuItem(); //新建菜单项对象
mnuChartOption.Name = "chart_option";
mnuChartOption.Text = "图形选项";
//点击弹出图形选项对话框
mnuChartOption.Click += delegate(object sender, EventArgs e)
{
};
menuStrip.Items.Add(mnuChartOption);
https://blog.csdn.net/badao_liumang_qizhi
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载 实现
ToolStripMenuItem mnuDirectPrint = new ToolStripMenuItem("直接打印");
mnuDirectPrint.Name = "directPrint";
mnuDirectPrint.Text = "直接打印";
mnuDirectPrint.Click += delegate(object sender, EventArgs e)
{
control.DoPrint();
};
ToolStripMenuItem mnuPrintPageSet = new ToolStripMenuItem("打印页面设置");
mnuPrintPageSet.Name = "printPageSet";
mnuPrintPageSet.Text = "打印页面设置";
mnuPrintPageSet.Click += delegate(object sender, EventArgs e)
{
control.DoPageSetup();
};
ToolStripMenuItem mnuPrint = new ToolStripMenuItem();
mnuPrint.Name = "mnuPrint";
mnuPrint.Text = "打印";
mnuPrint.DropDownItems.Add(mnuDirectPrint);
mnuPrint.DropDownItems.Add(mnuPrintPageSet);
menuStrip.Items.Add(mnuPrint);
效果
文章标题:C#中怎样在ToolStripMenuItem下再添加子级菜单
文章链接:http://soscw.com/index.php/essay/45300.html