Disable User Interaction on tree

3 posts, 0 answers
  1. Paul
    Paul avatar
    35 posts
    Member since:
    Jan 2014

    Posted 04 Dec 2014 Link to this post

    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. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 09 Dec 2014 Link to this post

    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.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Paul
    Paul avatar
    35 posts
    Member since:
    Jan 2014

    Posted 25 Dec 2014 in reply to Hristo Merdjanov Link to this post

    Hi Hristo,

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

    Thanks and merry christmas

    Andez
Back to Top