如何使用 VB.net (2008) 将节点添加到 WPF 树列表 [英] How to add nodes to a WPF treelist using VB.net (2008)
本文介绍了如何使用 VB.net (2008) 将节点添加到 WPF 树列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要创建一个 wpf 树视图列表来看起来像这样:
I need to create a wpf treeviewlist to look something like this:
AAAA
BBBB
....CCCC
....DDDD
.......EEEE
FFFFF
(上面的点是缩进)
我需要从 vb.net (2008) 代码中执行此操作.
I need to do this from vb.net (2008) code.
我花了很长时间试图弄清楚这一点,但到目前为止我所得到的只有:
I've spent an embarrassingly long amount of time trying to figure this out, and so far all I’ve got is:
vb.net:
Dim tvi1, tvi2 As TreeViewItem
tvi1 = New TreeViewItem
tvi2 = New TreeViewItem
Dim Node1 As Integer
tvi1.Header = "AAAA"
tvi2.Header = "BBBB"
Node1 = TreeView1.Items.Add(tvi1)
Node1 = TreeView1.Items.Add(tvi2)
任何指针或示例将不胜感激.
Any pointers or examples would be greatly appreciated.
谢谢,罗布
推荐答案
你可以很容易地做到这一点.只需将您的子 TreeViewItems 直接添加到父项,就像这样(C#,但很清楚)
You can do it quite easily. Simply add your child TreeViewItems directly to the parent item, like so (C#, but very clear)
var parent = new TreeViewItem();
var child = new TreeViewItem();
parent.Header = "Hey";
child.Header = "There!";
parent.Items.Add(child);
treeView1.Items.Add(parent);
这篇关于如何使用 VB.net (2008) 将节点添加到 WPF 树列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文