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

Text wrapping in a tree view node and multi line support

7 Answers 1128 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 14 Sep 2011, 04:29 PM
Hi,

I am using a RadTreeView to display a set of nodes where the text is very long. Is it possible to specify a max width for the treeview node and have the text wrap within the available space extending down (or clipping beyond the horizontal size). 

(I have read some other posts on this but there is nothing in there for this year)

Regards
James   

7 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 19 Sep 2011, 07:38 AM
Hi James,

Thank you for writing.

Currently, RadTreeView does not support text wrapping out of the box. However, if you know what height each node should have to accommodate its text, you set set the AllowArbitraryItemHeight to true, and then in NodeFormatting set the ItemHeight and TextWrap properties of the desired nodes:
private void radTreeView1_NodeFormatting(object sender, Telerik.WinControls.UI.TreeNodeFormattingEventArgs e)
{
    if (e.NodeElement.Text == "This is a node with long text")
    {
        e.NodeElement.ContentElement.TextWrap = true;
        e.NodeElement.ItemHeight = 50
    }
}

In regards to the text clipping, this is the default behavior of the control. Please refer to the attached image.

I hope that you find this information helpful. If there is anything else we can assist you with, do not hesitate to contact us.
 
Greetings,
Stefan
the Telerik team

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

0
Trey
Top achievements
Rank 2
answered on 30 Nov 2015, 05:46 PM

I am unable to read the Text property of the NodeElement in the NodeFormatting event.  It is always blank.  I am adding an element to the treeview as follows:

radTV.Nodes.Add("New Node");

0
Stefan
Telerik team
answered on 01 Dec 2015, 06:46 AM
Hi Tray,

You can access the text of the logical node using e.Node.Text, or if you want to work with the visual element, the text now resides in its e.NodeElement.ContentElement.Text.

I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Trey
Top achievements
Rank 2
answered on 01 Dec 2015, 02:14 PM

Stefan,

When I use either e.Node.Text or e.NodeElement.ContentElement.Text, the Text property is either blank or it gives the following error:

 '((Telerik.WinControls.UI.RadTreeViewNodeElementEventArgs)(e)).NodeElement' threw an exception of type 'System.ArgumentException'

 Richard

0
Stefan
Telerik team
answered on 02 Dec 2015, 08:06 AM
Hi Richard,

I would suggest that you open a support ticket where you can attach a sample project demonstrating the issue, so we can investigate the observed behavior, as I am not seeing such on my end. 

Looking forward to your support ticket.

Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Trey
Top achievements
Rank 2
answered on 02 Dec 2015, 02:33 PM

I don't have time to attach a sample project, and attaching my project will require a massive database.

 I am noticing that the NodeFormatting event is only being fired for first-level nodes, which is unacceptable since I often have 4 or 5 levels of nodes.

 I am able to do my formatting without using the NodeFormatting event, so I was able to work around the issue with the poor design of the radTreeView.

0
Stefan
Telerik team
answered on 02 Dec 2015, 03:40 PM
Hi,

NodeFormatting fires for every node in RadTreeView, when it needs to. You mentioned that you are adding the node in the Nodes collection, so it shouldn't be hard to isolate the issue in a sample, as it is not related to databases. You can just fill up a plain tree in a plain form with a couple nodes manually to replicate the scenario you have.

Should you decide to do so, feel free to send it over.

Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Treeview
Asked by
James
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Trey
Top achievements
Rank 2
Share this question
or