This is a migrated thread and some comments may be shown as answers.

Set icon/image based on node level

1 Answer 244 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 22 Jun 2012, 01:22 PM
Morning,

I'm wondering if there is an easy way of setting the image based on a node level in a tree?

GrandParent    -|
                          |
                          Parent  -|
                                        |
                                        Child
                                        Child
                                        Child

So for each level, I would be able to use the image list and assign 0 to GrandParent, 1 to Parents and 2 to child.  I do not care what the values of the 3 levels are, just its placement in the tree.

Thanks

James

1 Answer, 1 is accepted

Sort by
0
James
Top achievements
Rank 1
answered on 22 Jun 2012, 01:34 PM
Actual found an answer after posting this.  For anyone else who needs it, you can used the NodeFormatting.

private void radTreeView1_NodeFormatting(object sender, TreeNodeFormattingEventArgs e)

{

     e.Node.ImageIndex = e.Node.Level;

}

or 

if ( e.Node.Level == 0)
{
    e.Node.ImageIndex = xxx
}
else
if ( e.Node.Level == 1)
{
     e.Node.ImageIndex = yyy
}
etc.

James

Tags
Treeview
Asked by
James
Top achievements
Rank 1
Answers by
James
Top achievements
Rank 1
Share this question
or