在C#中的Treeview中添加节点 [英] add a node in treeview in c#

查看:458
本文介绍了在C#中的Treeview中添加节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,

我想在树视图中插入一个节点.

我使用treeview控件和上下文菜单条控件.
当我右键单击上下文菜单项1时,将在将生成节点的文本框中的任何文本之后生成文本框.


但是我的问题是,如何在所选节点下生成文本框.

Hi friends,

I want to insert a node in treeview.

I use treeview control and context menu strip control.
When I right click on context menu item 1 text box generate after whatever text in the text box that nodes will be generated.


But my problem is that how to generate a textbox below selected node.

推荐答案

可以使用文本框,但可能需要您做更多的工作.但是,如果您只是在寻找让用户能够编辑节点名称的方法,则可以始终使用树状视图上的现有功能

在树形视图上设置标签编辑
having the text box is possible but might need more work on you. but if you are just looking for a way for the user to be able to edit the name of the node you can always use the existing feature on the tree view

set the label edit on the tree view
treeView1.LabelEdit = true;




然后在您添加项目的上下文菜单事件中添加此代码




then in your context menu event where you add an item add this code

TreeNode nd = treeView1.SelectedNode.Nodes.Add("Add Name");
treeView1.SelectedNode.Expand();
nd.BeginEdit();



那么树状视图项目的文本将是可编辑的.

希望对您有帮助



then the tree view item text will be editable.

hope this helps


这篇关于在C#中的Treeview中添加节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆