Text wrapping in a tree view node and multi line support

8 posts, 0 answers
  1. James
    James avatar
    5 posts
    Member since:
    Aug 2011

    Posted 14 Sep 2011 Link to this post

    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   
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 19 Sep 2011 Link to this post

    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 >>

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Trey
    Trey avatar
    35 posts
    Member since:
    Dec 2006

    Posted 30 Nov 2015 in reply to Stefan Link to this post

    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");

  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 01 Dec 2015 Link to this post

    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
  6. Trey
    Trey avatar
    35 posts
    Member since:
    Dec 2006

    Posted 01 Dec 2015 in reply to Stefan Link to this post

    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

  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 02 Dec 2015 Link to this post

    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
  8. Trey
    Trey avatar
    35 posts
    Member since:
    Dec 2006

    Posted 02 Dec 2015 in reply to Stefan Link to this post

    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.

  9. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 02 Dec 2015 Link to this post

    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready