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

Disable autoscrolling on nodes with long text + tooltip

1 Answer 141 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Sergey
Top achievements
Rank 1
Sergey asked on 15 May 2014, 12:15 PM
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
 

1 Answer, 1 is accepted

Sort by
0
George
Telerik team
answered on 20 May 2014, 11:44 AM
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.
 
Tags
Treeview
Asked by
Sergey
Top achievements
Rank 1
Answers by
George
Telerik team
Share this question
or