Check RadTreeNode check box without effecting selection

2 posts, 0 answers
  1. Travis
    Travis avatar
    49 posts
    Member since:
    Dec 2012

    Posted 28 May 2013 Link to this post

    Is there a way to check or uncheck a RadTreeNode checkbox without effecting the selection? For our app, it's kind of handy that we can do both, but it's also useful that we check or uncheck without impacting the selection. Or possibly vice versa (current behavior) might be acceptable. In either case, ????
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 31 May 2013 Link to this post

    Hi Michael,

    Thank you for writing.

    To do that, you can inherit from RadTreeView and override the OnMouseDown method, where you can save the SelectedNode prior the base call and restore it right after. Here is an example:
    class MyTreeView : RadTreeView
    {
        protected override void OnMouseDown(MouseEventArgs e)
        {
            TreeNodeCheckBoxElement element = this.ElementTree.GetElementAtPoint(e.Location) as TreeNodeCheckBoxElement;
            if (element != null)
            {
                RadTreeNode saveSelectedNode = this.SelectedNode;
                base.OnMouseDown(e);
                this.SelectedNode = saveSelectedNode;
                return;
            }
            base.OnMouseDown(e);
        }
     
        public override string ThemeClassName
        {
            get
            {
                return typeof(RadTreeView).FullName;
            }
        }
    }

    I hope this helps.

    Regards,
    Stefan
    Telerik
    RadChart for WinForms is obsolete. Now what?
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top