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

Line numbers for tree nodes

8 Answers 348 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Marcus
Top achievements
Rank 1
Marcus asked on 05 Aug 2011, 09:53 PM
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)?

8 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 10 Aug 2011, 11:28 AM
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 >>

0
Marcus
Top achievements
Rank 1
answered on 10 Aug 2011, 12:15 PM
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.
0
Stefan
Telerik team
answered on 11 Aug 2011, 03:28 PM
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 >>

0
Marcus
Top achievements
Rank 1
answered on 24 Oct 2011, 04:08 PM
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.
0
Accepted
Stefan
Telerik team
answered on 25 Oct 2011, 11:13 AM
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.

0
Marcus
Top achievements
Rank 1
answered on 25 Oct 2011, 11:27 AM
Thanks.
0
Chummy
Top achievements
Rank 1
answered on 08 Nov 2011, 04:34 PM
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 
0
Stefan
Telerik team
answered on 11 Nov 2011, 12:52 PM
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.

Tags
Treeview
Asked by
Marcus
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Marcus
Top achievements
Rank 1
Chummy
Top achievements
Rank 1
Share this question
or