0

I am using xtratreelist in my application with only first level and I want to make some of the nodes visible but not all. Here is the code, but after that all the not are showing in the list

TreeList tr = new Treelist();

for (int x = 0; x < tr.Nodes.Count; x++)
{
    tr.Nodes[x].Visible = false;
}
Rajeev Kumar
  • 4,901
  • 8
  • 48
  • 83

2 Answers2

1

I suggest you use the NodesIterator, here is an example, and it works for me :

The data class :

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

And in my form :

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;
}
SidAhmed
  • 2,332
  • 2
  • 25
  • 46
0

Go through the following links

FindNodeByID

FindNodeByFieldValue

FindNodeByKeyID

Rajeev Kumar
  • 4,901
  • 8
  • 48
  • 83