我想在TreeView中添加一个表。这可能吗? 以下是我用来生成TreeView的以下C#代码:
var items = tree1.Items;
var item = new TreeViewItem() { Header = "End Item 1" };
items.Add(item);
var assemblies = new TreeViewItem() { Header = "Assemblies" };
var endpart = new TreeViewItem() { Header = "Parts" };
foreach (TreeViewItem n in items)
{
/// ASSEMBLIES
(n as TreeViewItem).Items.Add(assemblies);
/// ASSEMBLIES - ASSEMBLY 1
var subass = new TreeViewItem() { Header = "Assembly 1" };
foreach (TreeViewItem o in (n as TreeViewItem).Items)
{
if (o.Header == "Assemblies")
{
(o as TreeViewItem).Items.Add(subass);
// TABLE of PARTS
}
}
///PARTS
(n as TreeViewItem).Items.Add(endpart);
///PARTS - PART1
var subendpart = new TreeViewItem() { Header = "Part1" };
foreach (TreeViewItem p in (n as TreeViewItem).Items)
{
if (p.Header == "Parts")
(p as TreeViewItem).Items.Add(subendpart);
}
}
}
我想检索有关每个零件的数据,并将其包含在零件标题下的表格中。我怎么能这样做呢?