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

Losing multiple selection on mouse right click

8 Answers 250 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 22 Jun 2016, 01:11 PM

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

 

8 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 23 Jun 2016, 08:10 AM
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.
0
Peter
Top achievements
Rank 1
answered on 23 Jun 2016, 09:13 AM

Thanks Dimitar,

 

its works great.

 

Regards,

Peter

0
Peter
Top achievements
Rank 1
answered on 09 Aug 2016, 12:16 PM

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

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 09 Aug 2016, 01:23 PM
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.
0
Peter
Top achievements
Rank 1
answered on 10 Aug 2016, 06:59 AM

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

0
Hristo
Telerik team
answered on 12 Aug 2016, 01:51 PM
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.
0
rudi
Top achievements
Rank 1
answered on 06 Feb 2020, 12:15 PM
Thanks Dimitar, I had a similar issue. I am handling drag'n'drop with my own code, so the fact, that RadTreeView deselected multiple selections when pressing mouse down to drag, were driving me nuts, I tried selevra ugly workarrounds, but your suggestion, handling node elements, work like a charme. Thanks!
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Feb 2020, 10:38 AM
Hello, Rudi,   

I am glad that the suggested solution by my colleague, Dimitar, was helpful for achieving your goal.  

Note that in order to keep the multiple selected nodes in RadTreeView, it is necessary to keep the Ctrl key pressed while dragging.  

I would recommend you to have a look at the following help article demonstrating how to select multiple nodes and drag them to another RadTreeView. You can follow a similar approach and customize the TreeViewDragDropService in a way that suits your requirements best: https://docs.telerik.com/devtools/winforms/controls/treeview/drag-and-drop/modify-the-dragdropservice-behavior 

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Treeview
Asked by
Peter
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Peter
Top achievements
Rank 1
Peter
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Hristo
Telerik team
rudi
Top achievements
Rank 1
Share this question
or