我在我的应用程序中使用xtratreelist只有第一级,我想让一些节点可见但不是全部。这是代码,但之后所有不在列表中显示
TreeList tr = new Treelist();
for (int x = 0; x < tr.Nodes.Count; x++)
{
tr.Nodes[x].Visible = false;
}
答案 0 :(得分: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;
}
答案 1 :(得分:0)