Losing multiple selection on mouse right click

7 posts, 0 answers
  1. Peter
    Peter avatar
    2 posts
    Member since:
    Nov 2010

    Posted 22 Jun Link to this post

    Hi,

    I have a RadTreeView with MultiSelect = true. If I select more than one item in the tree and I right click the last selected item all items remain selected. If I right click any other of the selected items the current selection disappears and only the last clicked item is selected.

    I'm using Telerik for WinForms Q2 2016.

    You can test this behaviour with the WF Demo Application -> TreeView -> Selection

    What can I do to keep the current selection?

     

    Thanks in advance,

    Peter

     

  2. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 23 Jun Link to this post

    Hi Peter,

    Thank you for writing.

    To override the default behavior you need to create custom RadTreeViewElement. This way you can override the ProcessContextMenu and ProcessMouseDown methods. This will allow you to handle the case where a selected node is clicked:
    class MyRadTreeView : RadTreeView
    {
        protected override RadTreeViewElement CreateTreeViewElement()
        {
            return new MyTreeViewElement();
        }
        public override string ThemeClassName
        {
            get
            {
                return typeof(RadTreeView).FullName;
            }
     
     
        }
    }
    class MyTreeViewElement : RadTreeViewElement
    {
        protected override Type ThemeEffectiveType
        {
            get
            {
                return typeof(RadTreeViewElement);
            }
        }
        protected override bool ProcessContextMenu(Point location)
        {
     
            RadTreeNode node = this.GetNodeAt(location);
            if (node.Current || !node.Selected)
            {
                return base.ProcessContextMenu(location);
            }
     
            //add your custom action here
            return false;
     
     
        }
        protected override bool ProcessMouseDown(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                return base.ProcessMouseDown(e);
            }
     
            return true;
        }
    }

    Let me know if I can assist you further.
     
    Regards,
    Dimitar
    Telerik
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Peter
    Peter avatar
    2 posts
    Member since:
    Nov 2010

    Posted 23 Jun in reply to Dimitar Link to this post

    Thanks Dimitar,

     

    its works great.

     

    Regards,

    Peter

  5. Peter
    Peter avatar
    4 posts
    Member since:
    Aug 2016

    Posted 09 Aug in reply to Dimitar Link to this post

    Hi Dimitar,

    I am a new guy on Telerik and trying to use Telerik's controls.

    I encountered some problems that need your help.

    The question is how to hide/remove the gray outer border of RadTreeView and RadListView,I tried several ways,all failed.

     

    Best Regards,

    Peter

  6. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 09 Aug Link to this post

    Hello Peter,

    Thank you for writing. 

    In order to hide the borders for RadTreeView and RadListView you can use the following code snippet:
    this.radTreeView1.TreeViewElement.DrawBorder = false;
    this.radListView1.ListViewElement.DrawBorder = false;

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  7. Peter
    Peter avatar
    4 posts
    Member since:
    Aug 2016

    Posted 10 Aug in reply to Dess Link to this post

    Thanks Dess!

    That works.

    One more question.I am trying to make a popup menu using RadPanel,how to let the RadPanel act as other menu(when we click out of the RadPanel,the RadPanel will hide automatically).Is there the event of "LostFocus" so that I can write some reaction codes to set the RadPanel invisible?

    Regards,

    Peter

  8. Hristo
    Admin
    Hristo avatar
    714 posts

    Posted 12 Aug Link to this post

    Hello Peter,

    Thank you for writing back.

    The LostFocus is defined in the System.Windows.Forms.Control class so you would be able to use it together with a RadPanel. You can also consider using a RadCollapsiblePanel or a RadPopupEditor. Please check the following links with additional information:
    Please also note that we try to keep our forum threads focused on one topic. In case, you need information about other controls do not hesitate to send us a ticket or to ask in the appropriate forums.

    I hope this helps. Should you have further questions do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready