Disable multi selection with mouse

3 posts, 1 answers
  1. Antoine
    Antoine avatar
    5 posts
    Member since:
    Nov 2012

    Posted 01 Mar 2013 Link to this post

    Hello Telerik fellows,

    I'm currently using the RadTreeView with multiple selection mode set to active, and the internal drag n' drop also set to active.

    The problem is that many of the customers are disturbed with the multiple selection while trying to perform the drag n' drop of a single node.

    They click once on the node to drag, move the mouse down to drag the nodes, and they get all the nodes below selected while they just wanted to have the node dragged over those nodes.

    Clearly, they would have to click first to select the node, then click again to begin the DnD, I'm not discussing the implementation which is correct from my point of view.

    Anyway, in order to prevent this misusage, I'd like to selectively enable the multi-selection with ctrl/shift keyboard keys, and disabling the multi-selection with mouse.

    Is it possible without re-implementing the whole multi-selection feature ?

    Thanks in advance,

    Antoine.
  2. Answer
    Svett
    Admin
    Svett avatar
    728 posts

    Posted 05 Mar 2013 Link to this post

    Hello Antonie,

    Thank you for writing.

    You can disable multi-selection with mouse by overriding the
    ProcessMouseMove method of RadTreeViewElement. You should extend the RadTreeView control do achieve that:
    public class MyRadTreeView : RadTreeView
    {
        public MyRadTreeView()
        {
            this.ThemeClassName = typeof(RadTreeView).FullName;
        }
     
        protected override RadTreeViewElement CreateTreeViewElement()
        {
            return new MyRadTreeViewElement();
        }
     
        public class MyRadTreeViewElement : RadTreeViewElement
        {
            protected override Type ThemeEffectiveType
            {
                get
                {
                    return typeof(RadTreeViewElement);
                }
            }
     
            protected override bool ProcessMouseMove(MouseEventArgs e)
            {
                return false;
            }
        }
    }

    I hope this helps.

    Kind regards,
    Svett
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Join us for a FREE webinar to see all the new stuff in action.

    Interested, but can’t attend? Register anyway and we’ll send you the recording.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Antoine
    Antoine avatar
    5 posts
    Member since:
    Nov 2012

    Posted 05 Mar 2013 Link to this post

    Nice, tried and validated.
Back to Top