Line numbers for tree nodes

9 posts, 1 answers
  1. Marcus
    Marcus avatar
    17 posts
    Member since:
    Aug 2012

    Posted 05 Aug 2011 Link to this post

    I'm planning to use the treeview as an alternative for the listview component for displaying multiple lines that can:

    - indent
    - selected via checkbox
    - drag/drop
    - image per line (node)
    - collapse/group lines

    All can be done with the treeview. The only thing I have on my "wishlist" is a way to number the "lines" (= nodes). Is it possible to add lines numbers to the left of the notes, just like f.e. in a code editor (all aligned on the left before the nodes)?

  2. Stefan
    Admin
    Stefan avatar
    2360 posts
    Member since:
    Sep 2012

    Posted 10 Aug 2011 Link to this post

    Hi Marcus,

    Thank you for writing.

    RadTreeView does not support out of the box line (node) numbering functionality. Could you please share, in your opinion, how the control must behave if such functionality is implemented? What numbers should be used for the child nodes?

    One possible approach is adding appropriate numbers to the text of your items.

    I am looking forward to your reply.
     
    Greetings,
    Stefan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  3. Marcus
    Marcus avatar
    17 posts
    Member since:
    Aug 2012

    Posted 10 Aug 2011 Link to this post

    Hi Stefan,

    I want to have line numbers for every node; not only the child nodes.

    For example:

    1  Node1
    2  Node2
    3     - ChildNode1
    4     - ChildNode2
    5  Node3
    etc. etc.

    I already thought of the solution to simply add the line numbers to the text of the nodes, but visually that isn't the nicest approach imho.

  4. Stefan
    Admin
    Stefan avatar
    2360 posts
    Member since:
    Sep 2012

    Posted 11 Aug 2011 Link to this post

    Hello Marcus,

    Thank you for the clarification.

    Another approach is to create a custom TreeNodeElement, where you can add additional element to the node, and use this additional element to show the number. Attached you can find a sample implementation of the described approach. Feel free to customize it according to your needs.

    I hope that you find this helpful. Should you have any other questions, do not hesitate to contact us.
     
    Kind regards,
    Stefan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  5. Marcus
    Marcus avatar
    17 posts
    Member since:
    Aug 2012

    Posted 24 Oct 2011 Link to this post

    Somehow I'm not exceeding in translating you example to VB.NET, especially the code lines:

    radTreeView1.CreateNodeElement += New CreateTreeNodeElementEventHandler(radTreeView1_CreateNodeElement)
    radTreeView1.NodeFormatting += New TreeNodeFormattingEventHandler(radTreeView1_NodeFormatting)

    Can you provide me with an example in VB.NET? Thx.

  6. Answer
    Stefan
    Admin
    Stefan avatar
    2360 posts
    Member since:
    Sep 2012

    Posted 25 Oct 2011 Link to this post

    Hi Marcus,

    Thank you for writing back.

    Here are the described lines in VB.NET:

    AddHandler radTreeView1.CreateNodeElement, AddressOf radTreeView1_CreateNodeElement
    AddHandler radTreeView1.NodeFormatting, AddressOf radTreeView1_NodeFormatting

    Attached you can also find the full solution converted to VB.NET.

    Should you have any other questions, do not hesitate to contact us
     
    All the best,
    Stefan
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  7. Marcus
    Marcus avatar
    17 posts
    Member since:
    Aug 2012

    Posted 25 Oct 2011 Link to this post

    Thanks.

  8. Chummy
    Chummy avatar
    9 posts
    Member since:
    Aug 2011

    Posted 08 Nov 2011 Link to this post

    Hi Stefan, we are trying to achieve a similar bit of functionality. We would like the nodes, child nodes and items of the tree to have associated numbering ie

    1        
       1.1
       1.2
       1.3
    2
       2.1
       2.2
           2.2.1
           2.2.2

    I have also attached a screenshot of what we are looking for.

    We would appreciate any suggestions.

    Thanks
    Chummy 

  9. Stefan
    Admin
    Stefan avatar
    2360 posts
    Member since:
    Sep 2012

    Posted 11 Nov 2011 Link to this post

    Hello Chummy,

    Thank you for writing.

    The approach with your scenario is the same. The only difference is that we will move the NumberElement right before the TreeNodeContentElement in order to show the number in front of the text and we will add logic in the NodeFormatting event handler to calculate the correct number. Please refer to the attached project.

    Let me know if I can be of further help.

    Best wishes,
    Stefan
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Back to Top