C# XtraTreeList's AppendNode method takes too much time

918 Views Asked by At

I'm having a lot of troubles with adding nodes to a XtraTreeList.

The method I use is TreeList.AppendNode (more info about the method here).

Actual Results :

If I have a class called MyClass and I want to add a node to an existing node in my XtraTreeList.

If I do something like :

// tlTest is the XtraTreeList
tlTest.AppendNode(new MyClass(/* Some Arguments */), parentNode);

Noting is printed on the screen.

BUT, if I do something like :

// tlTest is the XtraTreeList
tlTest.AppendNode(new object[] (){/* Some Arguments without cast */}, parentNode);

This seems to work perfectly well !

Problem :

The problem with the second way of doing things is that it takes soooo much time / ressources for something like 200 child nodes to add. And I'm wondering if it has something to do with dynamic casting ...

Question :

Is there a better way of doing this ? Keeping the code as it is would not be a good idea as adding 200 child nodes takes about 6/7 seconds (which is a real pain for the end user).

1

There are 1 best solutions below

0
DmitryG On

It is necessary to use the TreeList.BeginUnboundLoad and TreeList.EndUnboundLoad methods to prevent unnecessary updates when you add multiple nodes in unbound mode.

From help-article:

The BeginUnboundLoad and EndUnboundLoad methods should be used to avoid excessive internal data updates when adding, deleting and modifying nodes in unbound mode. In bound mode, use the LockReloadNodes and UnlockReloadNodes methods instead.