I am trying to convert the ListView custom drag/drop handler from the sample to be used in the ultratree. I am trying to do the drag/drop from TreeA -> TreeB, and soon TreeA->TreeA
There is a drag / drop sample for the tree that installs with NetAdvantage. It doesn't drag from one tree to another, but there's really not much to that, you just have to create copies of the nodes and insert them into the tree at the right spot.
Maybe I should have been more specific.
The ListView example has the custom drawing where the icons and text are shown while dragging. I am trying to implement that in an UltraTree. I have the drawing part working, but when I drag the node on the 2nd tree I want to access my own DragDrop function in my form that contains the trees.
Okay, I'm not sure I understand the problem, then.
DmgInc said:when I drag the node on the 2nd tree I want to access my own DragDrop function in my form that contains the trees.
Why can't you do this? What's stopping you? What is this DragDrop function and what does it do? How does the ListView sample access it?
There's really no difference in the drag and drop behavior of the two controls. The Drag events are events on Control and all controls derive from Control and therefore all have the same events.
Yes, I am aware of how to do drag & drop.
Have you checked out that example in the listview?
Not to be out of line, but it is sounding you haven't, or haven't recently. The example uses custom classes to do the drawing, WinListViewDragSource.cs, WinListViewDropTarget.cs and DrapDropManager.cs, I have converted these to work with the treeview
In the WinListViewDropTarget.cs there is the method
void DragDropManager.IDropTarget.OnDropTargetNotify( DragDropManager.DropTargetNotifyInfo info )
inside that there is
case DragDropManager.DropTargetNotification.DragDrop:
I think I understand now - you want to incorporate the drag logic into a derived class so you don't have to implement the same solution on the application level every time you want to use it. The solution is to override the virtual event-raising methods for drag/drop: OnQueryContinueDrag and OnGiveFeedback for the drag source control, and OnDragOver and OnDragDrop for the drop target control. Where the sample registers as a listener for the corrresponding events, your UltraTree-derived class would have the same logic (that is currently in those event handlers) in the overridden methods.
Ok, I obviously suck at asking what I want :)
Let me try again, heh.
1) I know how to drag and drop between trees, been doing it for years
2) I stumbled across the listview drag/drop example and thought it was cool to show the icon/text while drag/dropping
3) I converted and implemented that in my treeview.
I want to keep this generic for all my trees, and since most of my trees have custom logic/functions I run on the _DragDrop event, so I would prefer to not have to write/use a different custom drag/drop class for every tree I have.
I'm afraid I don't understand exactly what problem you are trying to solve either.
DmgInc said:I have that part working, it is just getting it to fire my DragDrop event. I have tried numerous things in the custom class but I am at a loss on how to make it do that.
If you like you can post the relevant parts of the code for your "DragDrop event" and I can help you get from the sample's code to there.
Regarding your simplified question: to get custom drag cursors to be displayed instead of the default drag/drop cursors, set the 'UseDefaultCursors' property (of the event arguments for the 'GiveFeedback' event that every control inherits from the System.Windows.Forms.Control class) to false. When you do that, you are essentially signifying that you are going to handle the cursors, so the framework doesn't have to. In the context of this sample, UseDefaultCursors is set to false, and a drag or copy cursor is displayed, depending on the type of drag operation. An image is generated from the UIElements of the items being dragged, and that image is displayed (with the help of the Infragistics.Win.DragDropIndicatorManager class) while the drag operation is in progress. If you search the code for ".ShowDragImage", you will see where this is happening.
I attached a revised version of the sample that uses an UltraTree instead of an UltraListView.
Mike Saltzman"] Hm. I can't say that I know the sample inside out or anything. But I have looked it. And I still don't understand what you are asking. All the sample classes do is hook the events on the ListView control and handle them. It's a nice way to keep all the drag and drop logic centralized. But it doesn't really make any technical difference whether the event handlers are in the form or if they are inside a class.
Hm. I can't say that I know the sample inside out or anything. But I have looked it. And I still don't understand what you are asking.
All the sample classes do is hook the events on the ListView control and handle them. It's a nice way to keep all the drag and drop logic centralized. But it doesn't really make any technical difference whether the event handlers are in the form or if they are inside a class.
Ok, almost on the same page now :) Yes that example does hook the events, but it also adds the functionality of while dragging and dropping it shows the image and the text of the item you are dragging/dropping.
Since when you drag/drop in an UltraTree it doesn't show the image and the text wihle dragging and dropping. So I used that examples class to make it so my tree will drag/drop w/the image and text. I have that part working, it is just getting it to fire my DragDrop event. I have tried numerous things in the custom class but I am at a loss on how to make it do that.
Mike Saltzman"] So why can't you modify the classes to add your logic to the event handlers inside the class? Or call your DragDrop function from the event handler?
So why can't you modify the classes to add your logic to the event handlers inside the class? Or call your DragDrop function from the event handler?
Because I am trying to make it generic for all the trees I use.
I guess I could simplify this down to, how can I make the drag/drop of the treeview show the image and text while draggin and dropping?