I have a TreeList that is inside a PopupContainerControl.
The TreeList is populated dynamically depending on the context in which the form is being used. This means that the Node List is updated and modified during runtime.
The problem I am having is that the TreeList is only showing the first modification made to the node structure, but not any following that one.
I am using a Custom Node class that implements IVirtualTreeListData. Shown Below.
public class Node<T> : TreeList.IVirtualTreeListData
{
public Node<T> Parent { get; set; }
public List<Node<T>> Children { get; set; }
public object[] Cells { get; set; }
public T Object { get; set; }
public Node(T t, Node<T> parent, object[] cells)
{
Parent = parent;
Children = new List<Node<T>>();
Cells = cells;
Object = t;
if (this.Parent != null)
this.Parent.Children.Add(this);
}
public Node(Node<T> parent, object[] cells)
{
Parent = parent;
Children = new List<Node<T>>();
Cells = cells;
if (this.Parent != null)
this.Parent.Children.Add(this);
}
public void VirtualTreeGetChildNodes(VirtualTreeGetChildNodesInfo info)
{
info.Children = Children;
}
public void VirtualTreeGetCellValue(VirtualTreeGetCellValueInfo info)
{
info.CellData = Cells[info.Column.AbsoluteIndex];
}
public void VirtualTreeSetCellValue(VirtualTreeSetCellValueInfo info)
{
Cells[info.Column.AbsoluteIndex] = info.NewCellData;
}
}
So when I first load the form, I make the following call.
_rootNode = new Node<MyResource>(null,null)
_treeList.DataSource = _rootNode;
Later, when the resources are loaded into the TreeList, it looks like the following:
Node<MyResource> newResourceNode = new Node<MyResource>(_rootNode,new object[]{"New Node"});
treeList.DataSource = _rootNode;
treeList.RefreshDataSource();
treeList.ExpandAll();
This will set the resources in the TreeList the FIRST time it is hit only, but not reflecting any following changes.
After change the datasource of the treelist, you can try:
You also need to keep the "BeginUpdate()" and "EndUpdate()" used same time, it will impact the "TreeList.IsLockUpdate" value,if you find "TreeList.IsLockUpdate" is "True",try to clear whether lack of "EndUpdate" in running time.