Change child node position

2 posts, 0 answers
  1. Eduard
    Eduard avatar
    7 posts
    Member since:
    Jul 2012

    Posted 26 Sep 2014 Link to this post


    Is it possible to change all the child nodes position, to align with the root node. So all the nodes (root and child) will be aligned at the left. 
    And one more question. Is it possible to change the color inside the checkbox or the radio button, and the text in black (in a treeview with checkboxes and radio buttons). 

    Thank you in advance

  2. Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    3626 posts

    Posted 30 Sep 2014 Link to this post

    Hello Eduard,

    Thank you for writing.

    In order to achieve your goal it is suitable to use the NodeFormatting event. Thus, for all nodes from the child levels you can adjust the NodeElement.Margin property:
    private void radTreeView1_NodeFormatting(object sender, TreeNodeFormattingEventArgs e)
        if (e.Node.Level>=1)
            e.NodeElement.Margin = new Padding(-20*e.Node.Level, 0, 0, 0);
             e.NodeElement.Margin = new Padding( 0);

    As to the check mark, you can adjust its back color in the NodeFormatting event as well:
    TreeNodeCheckBoxElement cb = e.NodeElement.ToggleElement as TreeNodeCheckBoxElement;
    if (cb != null)
        cb.CheckMarkPrimitive.Fill.BackColor = Color.Yellow;
        cb.CheckMarkPrimitive.Fill.GradientStyle = GradientStyles.Solid;              

    The node's text can be customized via the e.NodeElement.ContentElement.ForeColor property:
    e.NodeElement.ContentElement.ForeColor = Color.Red;

    I hope this information helps. Should you have further questions, I would be glad to help.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
Back to Top