Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
740
Loading Node Images takes time
posted

Hi Guys,

I have a UltraTree which loads data for different types of sport items. Following shows how the tree should be displayed:

- Cricket

         Cricket1

                Cricket1.1

                     Cricket1.1.1

                Cricket1.2

                      Cricket1.2.1

         Cricket2

- FootBall

          FootBall1

                  FootBall1.1

                        FootBall1.1.1

                  FootBall1.2

          FootBall2

-----------

------------ and Goes on..

I want to set different images for different types. For example, for Cricket and its CHILD nodes ( Cricket1,  Cricket1.1,  Cricket1.1.1, Cricket2 etc.), should load Cricket image, and for FootBall and its Child Nodes FootBall(FootBall1, FootBall1.1, FootBall1.1.1,FootBall2 etc.) should load FootBall image etc.

I have set some apperenaces and when i try to load the tree using follwing code, it takes a looooong time. Is there a way to overcome this delay and would like to know any different approach i can use to load this images.

private void LoadTree()

{

this.utComponentTree.DataSource = this.componentBindingSource;

this.utComponentTree.DataMember = "component$fk_componen_comp_topl_componen";

componentBindingSource.DataSource = treeVluesTable; // table which has the tree data

Infragistics.Win.Appearance aAppearance;aAppearance = this.utComponentTree.Appearances.Add("Cricket");

aAppearance.Image = 0;

aAppearance =
this.utComponentTree.Appearances.Add("FootBall");

aAppearance.Image = 1;

SetApperance(this.utComponentTree.Nodes[0], utComponentTree.Appearances["Cricket"]);

SetApperance(this.utComponentTree.Nodes[1], utComponentTree.Appearances["FootBall"]);

 

}

private void SetApperance(UltraTreeNode node, Infragistics.Win.Appearance appearance)

{

node.Override.NodeAppearance = appearance;

List<UltraTreeNode> descendants = this.GetAllDescendants(node);for (int i = 0; i < descendants.Count; i++)

descendants[i].Override.NodeAppearance = appearance;

}

private List<UltraTreeNode> GetAllDescendants(UltraTreeNode node)

{

List<UltraTreeNode> retVal = new List<UltraTreeNode>();

this.GetAllDescendants(node.Nodes, retVal);

return retVal;

}

private void GetAllDescendants(TreeNodesCollection nodes, List<UltraTreeNode> descendants)

{

foreach (UltraTreeNode node in nodes)

{

descendants.Add(node);

if (node.HasVisibleNodes)this.GetAllDescendants(node.Nodes, descendants);

}

}

Urgent Help Needed!! Any questions welcome! Thanks in Advance.

Nw

 

Parents
No Data
Reply
  • 69832
    Offline posted

    I looked into this once before and it was caused by the use of an ImageList; when an index is specified as the value of the Image property, performance was getting hit through the act of using the indexer. I also looked into why the .NET TreeView control did not seem to have the same problem, and it was because they were using internal methods to get at the ImageList, which are not available to us. The solution was very simple though - instead of assigning (for example) 0 to the Image property, assign a reference to the Image itself, i.e., ImageList.Images[0].

Children