Set icon/image based on node level

2 posts, 0 answers
  1. James
    James avatar
    4 posts
    Member since:
    Jul 2012

    Posted 22 Jun 2012 Link to this post

    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
  2. James
    James avatar
    4 posts
    Member since:
    Jul 2012

    Posted 22 Jun 2012 Link to this post

    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

  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top