I'm just looking at adding drag and both directions between my tree and grid, have the simple sample and am wondering if there is a general drag and drop overview article to help me get started. I would especially like to know the following:
- how to display a drop allowed/not allowed and to prevent a drop if the wrong type of object.
- how to drag a row/node away so as to delete the object. And to confirm this is what is wanted.
- any other D+D best practices.
Thanks, Dave
Hi Dave,
Drag and drop are pretty much the same for every control. So I don't think there is any documentation on these topics specific to Infragistics. You might want to check out Microsoft's docs on the drag and drop events.
codeslinger said:- how to display a drop allowed/not allowed and to prevent a drop if the wrong type of object.
Basically, you handle this inside the drag events. There are properties on the event args that determine what types of drops are allowed.
codeslinger said:- how to drag a row/node away so as to delete the object. And to confirm this is what is wanted.
Not sure what you mean by "confirm this is what is wanted", but how you remove a node from the tree depends on how the tree gets it's data. If it's bound, then you would have to remove the item from the underlying data source. If it's not bound, you can simply remove the node using the Remove method. The grid is always bound, so you have to remove the item from the underlying data source.
codeslinger said:- any other D+D best practices.
Again, this is probably best explained in Microsoft's docs. I would start by looking up the various events like DragDrop and DragOver (or is it DragMove, I always mix them up) on MSDN.
The only slightly tricky part of this in terms of the Infragistics controls is determining what's under the mouse at a particular point. You do this using UIElements. Here's a KB article that will point you in the right direction.
HOWTO:UltraWinGrid Mouse Position and Row Identification
Note that this article is using a point from the Mouse events and that Mouse events give you the coords in control coordinates. Drag events give you the coords in screen coordinates. So you have to call ScreenToClient before you pass them into the ElementFromPoint method.
Thanks Mike. I had actually never done any D&D before but I have figured out how it works now pretty much and see that you follow the basic MSFT model. I do have a basic drag and drop framework working but have a couple more questions if I could.
1. Regarding removing a node or row, I'm not concerned how to actually remove it but rather what event my drag source will get if I drag a node off to somewhere that will not accept a drop, such as somewhere on the desktop away from my app, and then drop it anyway. And is the proper way to drag for a delete?
2. Is it normal to pop a dialog on the DragDrop event to ask the user if they want to move, copy, delete the node/row as appropriate if it is not already clear from the context?
3. Is there a way to check if it was dropped with the LMB or RMB?