0

我在我的应用程序中使用 xtratreelist,只有第一级,我想让一些节点可见,但不是全部。这是代码,但之后所有未显示在列表中

TreeList tr = new Treelist();

for (int x = 0; x < tr.Nodes.Count; x++)
{
    tr.Nodes[x].Visible = false;
}
4

2 回答 2

1

我建议您使用NodesIterator,这是一个示例,它适用于我:

数据类:

public class Service
{
    public string Name { get; set; }
    public bool Visible { get; set; }
}

并以我的形式:

private void TreeForm_Load(object sender, EventArgs e)
{
     treeList1.DataSource = Service.GetServices();
     treeList1.NodesIterator.DoLocalOperation(setNodeVisibility, treeList1.Nodes);
}

private void setNodeVisibility(DevExpress.XtraTreeList.Nodes.TreeListNode node)
{
     var service = treeList1.GetDataRecordByNode(node) as Service;
     if (service == null)
         return;

     node.Visible = service.Visible;
}
于 2013-05-20T17:05:44.473 回答
0

浏览以下链接

FindNodeByID

FindNodeByFieldValue

FindNodeByKeyID

于 2013-05-20T11:14:28.637 回答