Drag Icon

Hi all together,
i'm using the TreeViewAdv and do some DragDrop Operations.
What i'm looking for is a example of how to:

-Check Nodes on DragOver if dropping is allowed
-according to allow dropping set a DargIcon

Thanks
Peter


3 Replies

VR Vijayalakshmi Roopkumar Syncfusion Team February 3, 2018 11:59 AM UTC

Hi Forstmeier

Thank you for contacting Syncfusion Support.

We have prepared a sample that tries to meet your requirement. From your update, we understood that your requirement is to restrict some nodes to drop the items. For this, you can handled it using the TreeViewAdv PreviewDrop event. In our sample, we have restricted the Dropping of items for some nodes and updated the icon accordingly. The same has been demonstrated in our following sample. Please find the code example for the same.

Code example:[C#]
 
private void TreeViewAdv1_PreviewDrop(object sender, DragEventArgs e) 
{ 
TreeViewAdv item = sender as TreeViewAdv; 
 
TreeViewItemAdv itemnew = VisualUtils.FindDescendant(item, typeof(TreeViewItemAdv)) as TreeViewItemAdv; 
if (itemnew != null) 
{ 
foreach (TreeViewItemAdv items in itemnew.Items) 
{ 
if (items == e.Source && ((items.Header.ToString() == "Contacts") || (items.Header.ToString() == "Calendar"))) 
{ 
 
if (items.AllowDrop == true) 
{ 
e.Handled = true; 
items.LeftImageSource = new BitmapImage(new Uri(@"\images\wrong.gif", UriKind.RelativeOrAbsolute)); 
} 
 
} 
else if(items == e.Source && (((items.Header.ToString() != "Contacts") || (items.Header.ToString() != "Calendar")))) 
{ 
e.Handled = false; 
items.LeftImageSource = new BitmapImage(new Uri(@"\images\right.gif", UriKind.RelativeOrAbsolute)); 
 
} 
} 
} 
} 
Screenshot

Please try this solution and let us know if it is helpful.

Regards
Vijayalakshmi V.R.
 



FP Forstmeier Peter February 5, 2018 09:02 AM UTC

Hi,
thanks for the sample but this sample didn't do what i'm looking for.

During Drag i pass some nodes. These nodes have to be checked if Drag is allowed or not, and the Icons have to Change according the check.Sorry for that.

Peter


VR Vijayalakshmi Roopkumar Syncfusion Team February 7, 2018 10:40 AM UTC

Hi Forstmeier

Thank you for the update.

We have modified the sample that tries to meet your requirement.

In our sample, we have checked the nodes if it AllowDrop or not in PreviewDragOver event of TreeviewAdv and change the icon accordingly. Please download the sample for the same from following location:


Sample: http://www.syncfusion.com/downloads/support/forum/135719/ze/TreeViewDragDropSample_Modified1194051403 

Also, we have checkd the nodes if it allow drag or not in DragStart event of TreeviewAdv and change the icon accordingly. The same has been downloaded from following location:

Sample: http://www.syncfusion.com/downloads/support/forum/135719/ze/TreeView_dragcheck1706749109 

Please try this solution and let us know if it is helpful

Regards
Vijayalakshmi V.R. 


Loader.
Up arrow icon