Preventing horizontal auto-scrolling on radtreeview with long node names
I have a winform RadTreeView that has long names for the nodes and in a small area of the application. When I click the checkbox next to the node name to check it, the node gets selected and the window scrolls right which prevents the check box from being checked and we have to scroll back to check the node. We can check the nodes with long names as long as it is already selected but when your checking a node that isn't selected it scrolls. Is there anyway to prevent the auto scrolling of the RadTreeView to the end of the node name? We are running the latest version which it is suppose to be fixed in but it is still happening.开发者_如何学运维 Thanks!
To prevent auto-scrolling, you can apply the following style to the TreeView:
<telerik:RadTreeView runat="server" style="overflow:hidden;" ... />
See this article for more details:
http://www.telerik.com/support/kb/aspnet-ajax/treeview/controlling-radtreeview-scrollbars-visual-appearance.aspx
EDIT
For WinForms, add the following to your code-behind:
public Form1()
{
InitializeComponent();
this.radTreeView1.HScrollBar.VisibleChanged += new EventHandler(HScrollBar_VisibleChanged);
}
void HScrollBar_VisibleChanged(object sender, EventArgs e)
{
this.radTreeView1.HScrollBar.Visible = false;
}
I got a response back from Telerik on this and they said it is a known issue which will be address in one of their future releases. Until then, you can work around it by creating a custom RadTreeView and RadTreeViewElement by inheriting the respective control/element and overriding some methods and properties. The method which would prevent the scrolling is called EnsureNodeVisibleHorizontale and is a part of the tree view element. Apart from this method you will have to override the method that creates the tree view element in the RadTreeView so it would return your element. The other two necessary overrides are for the theming mechanism.
精彩评论