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
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
Thanks Dimitar,
its works great.
Regards,
Peter
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
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
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
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:
- http://docs.telerik.com/devtools/winforms/panels-and-labels/collapsiblepanel/overview
- http://docs.telerik.com/devtools/winforms/editors/popupeditor/popupeditor
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
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