排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2024TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:50010702506256
欢迎加群交流技术
分类:
.NET
代码如下:
public partial class Form1 : Form { public Form1() { InitializeComponent(); treeView1.Nodes.Add("aa"); treeView1.Nodes.Add("bb"); treeView1.Nodes.Add("cc"); //右键菜单 ContextMenuStrip contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(); ToolStripMenuItem menuItem = new ToolStripMenuItem(); menuItem.Text = "子节点"; menuItem.Click += menuItem_Click; ToolStripMenuItem toolStripDropDown = new ToolStripMenuItem(); toolStripDropDown.Text = "一级"; ToolStripMenuItem toolStripDropDown2 = new ToolStripMenuItem(); toolStripDropDown2.Text = "二级"; menuItem.DropDownItems.Add(toolStripDropDown); menuItem.DropDownItems.Add(toolStripDropDown2); contextMenuStrip.Items.Add(menuItem); contextMenuStrip.Items.Add("修改"); contextMenuStrip.Items.Add("添加"); treeView1.ContextMenuStrip = contextMenuStrip; } void menuItem_Click(object sender, EventArgs e) { MessageBox.Show("点击"); } }
效果如下:
欢迎加群讨论技术,群:677373950(满了,可以加,但通过不了),2群:656732739
评价