View previous topic :: View next topic |
Author |
Message |
rnemchev
Joined: 26 Apr 2010 Posts: 12
|
Posted: Mon May 17, 2010 2:25 pm Post subject: DragDropEffects.Link Cursor |
|
|
Hi,
I have implemented drag and drop using appropriate events of the virtual tree. However when I set drag/drop effect to DragDropEffects.Link in GetRowDropEffect handler the shown cursor is wrong - instead of link cursor I get DragDropEffects.None (forbidden) cursor. When I set drag/drop effect to Move or Copy everything is OK (the proper cursors are shown).
I tried to set my own cursor using ViretualTree.DragLinkCursor property but without success.
Can you give me a clue? |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue May 18, 2010 12:19 am Post subject: |
|
|
Are you trying to drag into or from VirtualTree (or both)?
I think that probably you have handled the GetRowDropEffect event however you haven't handled the GetAllowedRowDropLocations event. If you are dragging custom data into VirtualTree then you will need to handle this event and set the e.AllowedDropLocations - otherwise you won't be allowed to drop the data. I've checked by modifying the Simple Tree sample and was able to set the RowDropEffect to link without any issues (ie it displayed the link cursor). _________________ Infralution Support |
|
Back to top |
|
|
rnemchev
Joined: 26 Apr 2010 Posts: 12
|
Posted: Tue May 18, 2010 8:52 am Post subject: |
|
|
I have handled both GetRowDropEffect event and GetAllowedRowDropLocations event. I suspect that because my drag starts from the tree and the drop is in the same tree the link behavior is not allowed.
This is my implementation (I am using custom IList implementation for binding):
protected override RowDropLocation AllowedRowDropLocations( Row row, IDataObject data )
{
return RowDropLocation.OnRow;
}
protected override bool AllowRowDrag( Row row )
{
return true;
}
protected override DragDropEffects RowDropEffect( Row row, RowDropLocation dropLocation, IDataObject data )
{
return DragDropEffects.Link;
} |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue May 18, 2010 9:39 am Post subject: |
|
|
You are right there is an issue when Virtual Tree is the source of the drag event. The reason for this is rather curious. To initiate the drag operation the RowWidget.DoDragDrop method calls:
Code: | WidgetControl.DoDragDrop(this, Tree.SelectedRows.GetRows(), DragDropEffects.All); |
However strangely enough (and contrary to the Microsoft documentation) DragDropEffects.All does not include DragDropEffects.Link. To work around this issue you can override the VirtualTree.DoDragDrop method as follows to force the allowed drag effects to include Link:
Code: | class MyTree : VirtualTree
{
public override void DoDragDrop(Widget widget, object data, System.Windows.Forms.DragDropEffects allowedEffects)
{
allowedEffects = allowedEffects | DragDropEffects.Link;
base.DoDragDrop(widget, data, allowedEffects);
}
} |
We will change the RowWidget.DoDragDrop method in a future release to explicity include the Link effect (instead of using .All) _________________ Infralution Support |
|
Back to top |
|
|
rnemchev
Joined: 26 Apr 2010 Posts: 12
|
Posted: Tue May 18, 2010 2:54 pm Post subject: |
|
|
Thank you! Your solution works fine.
Rado |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Jun 29, 2010 2:29 am Post subject: |
|
|
Version 3.15.1 has now been released and fixes this issue (so that you do not need to override DoDragDrop) _________________ Infralution Support |
|
Back to top |
|
|
|