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)
7 Answers, 1 is accepted
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:
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.
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
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:
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.
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'
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.
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.
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.