windows 如何让每个 Treeview 节点都有一个相关的 TextBox
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/325366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make each Treeview Node have a related TextBox
提问by JonasB
I am trying to make a form in which the user fills in values. It is quite long. I wish to use an expandable tree to fit it into my one form. Is there any way to give each TreeView Node a TextBox by its side? Having the node text edited by itself is not enough.
我正在尝试制作一个用户填写值的表单。它很长。我希望使用可扩展的树来适应我的一种形式。有没有办法给每个 TreeView 节点一个旁边的 TextBox?单独编辑节点文本是不够的。
回答by Marc Gravell
Is the textbox for editing the node? or for secondary data? If the node, it can already be editable (Edit/BeginEdit or something). If secondary data, I would be quite tempted to push this into a single textbox that displays/edits the data for the current selected node. That may text-boxes is going to be confusing!
是编辑节点的文本框吗?还是二手资料?如果节点,它已经可以编辑(编辑/开始编辑或其他东西)。如果是辅助数据,我很想将其推送到显示/编辑当前选定节点数据的单个文本框中。那可能文本框会令人困惑!
Alternatively, there are some treeview/grid combined controls available from 3rd parties. Might be a good fit. Here's(look for TreeListView
) a quick search hit (not a specific recommendation - just a search result).
或者,有一些来自 3rd 方的树状视图/网格组合控件可用。可能很合适。这是(查找TreeListView
)快速搜索结果(不是特定推荐 - 只是搜索结果)。
回答by Gonzalo Quero
You can create the textBox in the TreeNode.Tag and then draw the textbox based on the actual TreeNode position.
您可以在 TreeNode.Tag 中创建文本框,然后根据实际的 TreeNode 位置绘制文本框。
回答by Gonzalo Quero
Don't use useless 3rd party controls, as they are native in Windows ! (in particular the TreeListView, which is native since NT 3.5)
不要使用无用的 3rd 方控件,因为它们是 Windows 原生的!(尤其是自 NT 3.5 起原生的 TreeListView)