Disable autoscrolling on nodes with long text + tooltip

2 posts, 0 answers
  1. Sergey
    Sergey avatar
    1 posts
    Member since:
    Oct 2013

    Posted 15 May 2014 Link to this post

    Hi

    I'm working with radtreeview and have nodes with long names (see the picture). When i click on such nodes radtreeview make horizontal autoscrolling and do not showing the tooltip. How can i disable autoscrolling (but scroller must be visible) and show tooltip for such items with its text). I set property ShowItemTooltip to TRUE, but tooltip is not showing.

    Thanks.
     
    English (auto-detected) » Russian
     
  2. George
    Admin
    George avatar
    500 posts

    Posted 20 May 2014 Link to this post

    Hello Sergey,

    Thank you for writing.

    In order to show tool tips, you need to set the ShowNodeToolTips property to true. Then you need to subscribe to the ToolTipTextNeeded​ event:
    void TreeView_ToolTipTextNeeded(object sender, ToolTipTextNeededEventArgs e)
    {
        if (sender is TreeNodeElement)
        {
            e.ToolTipText = (sender as TreeNodeElement).Data.Text;
        }
    }

    As to the autoscrolling, I am guessing that you refer to the case where you click a child node which's text is visually longer than its parent. In this case RadTreeView tries to position it and scrolls the horizontal scrollbar. This will require you to create a custom RadTreeView and override the EnsureNodeVisibleHorizontal method:
    public class MyTree : RadTreeView
    {
        protected override RadTreeViewElement CreateTreeViewElement()
        {
            return new MyTreeViewElement();
        }
     
        public override string ThemeClassName
        {
            get
            {
                return typeof(RadTreeView).FullName;
            }
            set
            {
            }
        }
    }
     
    public class MyTreeViewElement : RadTreeViewElement
    {
        protected override void EnsureNodeVisibleHorizontal(RadTreeNode node, TreeNodeElement nodeElement)
        {
            //we stop the base logic here
        }
     
        protected override Type ThemeEffectiveType
        {
            get
            {
                return typeof(RadTreeViewElement);
            }
        }
    }

    I have also enclosed a small sample which demonstrates the above approaches.

    Let me know if you require further assistance.

    Regards,
    George
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top