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

Disable User Interaction on tree

2 Answers 271 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 04 Dec 2014, 11:14 PM
Hi,

I am populating the treeview's nodes on a Task in the background.  As part of this, I want to prevent the user performing any actions on the treeview, such as clicking nodes etc.  Therefore I want to disable any mouse and keyboard input/interactions.

SuspendUpdate is no good as I still want to be able to resize a form and the control to resize too.  Also setting Enabled to false will not suffice as this greys out the control.

Thanks

Andez

2 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 09 Dec 2014, 04:09 PM
Hello Andez,

Thank you for writing.

A possible way to accomplish this task would be to create a custom class which extends the RadTreeView and overrides the base behavior of all methods responsible for user interaction either from the keyboard or from the mouse input. Please do not forget to also override the ThemeClassName in order to keep the theme styles applied to the inherited control. Below is a code snippet with a sample implementation:
public class CustomRadTreeView : RadTreeView
{
    public override string ThemeClassName
    {
        get
        {
            return typeof(RadTreeView).FullName;
        }
    }
    //Stops keyboard navigation
    protected override void OnKeyDown(KeyEventArgs e)
    {
        return;
    }
  
    //Stops collapse/expand
    protected override void OnMouseUp(MouseEventArgs e)
    {
        return;
    }
  
    //Stops collapse/expand
    protected override void OnMouseDoubleClick(MouseEventArgs e)
    {
        return;
    }
  
    //Stops nodes selection
    protected override void OnMouseDown(MouseEventArgs e)
    {
        return;
    }
  
    //Stops hot tracking
    protected override void OnMouseMove(MouseEventArgs e)
    {
        return;
    }
}

I hope that you find this information useful. Should you have any other questions, please do not hesitate to contact us.

Regards,
Hristo
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Paul
Top achievements
Rank 1
answered on 25 Dec 2014, 08:40 PM
Hi Hristo,

I thought as much.  Wasn't sure if there was an option or not.

Thanks and merry christmas

Andez
Tags
Treeview
Asked by
Paul
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Paul
Top achievements
Rank 1
Share this question
or