Desktop app - Listview drag-and-drop to treeview

1 Answer 109 Views
ListView Treeview
Peter
Top achievements
Rank 1
Peter asked on 18 Apr 2023, 05:47 PM

Is there a Desktop equivalent example of this example?

https://demos.telerik.com/aspnet-ajax/listbox/examples/applicationscenarios/treeviewdraganddrop/defaultcs.aspx

I'm struggling to figure out the way to handle this. I have a treeview showing a list of accounts, and a treeview that allows for grouping these accounts in a hierarchy. Both have underlying classes that are populated from a database.

I'd like to allow my front-end users to drag and drop accounts from the listView to the treeView. The one attribute they have in common is an AccountNumber. All other attributes in the Hierarchy can be derived from other controls on the form. 

I read about adding a DataConverter, but cannot figure out how to implement this. For example, on this page: https://docs.telerik.com/devtools/wpf/controls/dragdropmanager/behaviors/listboxdragdropbehavior
it has a reference to DataConverter (but the definition for that seems to lack). 

The other references I've seen is to a DragDropManager, but I don't seem to be able to find concrete examples for Desktop for that, either.

Googling so far hasn't really helped.

Any assistance would be greatly appreciated!

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 19 Apr 2023, 09:54 AM

Hello Peter,

As I understand you are using the Telerik UI for WPF and its RadTreeView control. If that is the case, you can check the following resources:

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Peter
Top achievements
Rank 1
commented on 19 Apr 2023, 10:09 AM

Hi Martin,

Thanks for your reply. I *think* I'm using Telerik for WinForms. Is there an easy way to tell the difference so I know for sure which one I'm using? And is it safe to assume that there isn't much of a difference between the implementation?

Thank you.

 

Peter

Martin Ivanov
Telerik team
commented on 19 Apr 2023, 10:58 AM

You can tell by checking your Visual Studio's project setup. If you have a WPF project then probably you are using the Telerik's WPF RadTreeView. You can also indicate that by the APIs. In case you define the TreeView in XAML, then you are using WPF. The assembly from which RadTreeView originates also should tell you what platform you are using. The WPF one is in the Telerik.Windows.Controls.Navigation.dll. The WinForms one is in Telerik.WinControls.UI.dll.

The RadTreeViews in WPF and WinForms have different implementations and APIs.

 

Peter
Top achievements
Rank 1
commented on 19 Apr 2023, 11:01 AM

Hi Martin,

Thank you. We're using the WinControls.UI version. Are there similar examples for those available anywhere?

Thanks.

Peter

Dess | Tech Support Engineer, Principal
Telerik team
commented on 20 Apr 2023, 01:01 PM

Hi, Peter,

RadListView from the UI for WinForms suite handles the whole drag and drop operation by its ListViewDragDropService. The following article demonstrates a sample approach how to handle the public events offered by the service to achieve the desired drag and drop functionality:

https://docs.telerik.com/devtools/winforms/controls/listview/drag-and-drop/drag-and-drop-using-raddragdropservice 

Although it uses a RadGridView as a target control, it can be adopted to RadTreeView as well. You can detect what is the HitTarget in the PreviewDragOver event and use this object for further managing of the drop operation in the PreviewDragDrop event. Please give it a try and see how it works for your scenario.

Tags
ListView Treeview
Asked by
Peter
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or