I am currently working in VS 2010 with VB. I have an UltraTree control (NetAdvantage 12.2 Win CLR4x) that I have been able to drag and drop nodes at any given level and at any point. In other words, I can drag between nodes or on nodes.
I have already been able to highlight the node that the mouse is dragging over. WHAT I NEED: I also need the ability to draw a line between the nodes as I am dragging and about to drop. This will give my users the visual of WHERE the dragged node will be INSERTED within the tree.
Can anyone help me?
bmw
Hi bmw,
A possible approach to achieve this might be by using a 'DrawFilter'.
You could read about it at the following link: http://help.infragistics.com/Help/NetAdvantage/WinForms/2013.1/CLR4.0/html/Win_Draw_Filter.html.
The above approach is not so recommended, because it features element drawing, creating or removing and could lead to some unexpected behaviors. Please do not hesitate to ask if something comes up.
I wanted to know if you were able to solve your issue based on these suggestions or you still need help. Please let me know.
Hello Brenda,
You can to use the Clone method on the selected node when dragging from Tree 2 and 3, inside the their respective SelectionDragStart events. Do you want to copy or move nodes from Tree 2 and 3? Please see my attached sample for further details. We are currently working on dropping the node on the desired location.
Please let me know if you have any additional questions.
Hello Michael,
Thank you for responding so quickly! I appreciate it!
I just want to COPY from Tree 2 and 3. Tree 1 is used to modify/build a report hierarchy, while Trees 2 and 3 supply the elements that can be included in Tree 1. When an element is dragged from Tree 2 or 3 to Tree 1, I want to disable the node in Tree 2 or 3 to indicate that it already exists in Tree 1. Cloning is a good idea, but Tree 1's hierarchy can get rather large and I do not want to just "ADD" the element from Trees 2 and 3 to Tree 1 and then drag to the position. I would like to be able to grap a Tree 2 or 3 element and just drag it to Tree 1 - dropping it at the desired location.
For some reason, I can MOVE elements from Trees 2 and 3, dropping into Tree 1 at any desired location, but it will NOT let me COPY. I find that rather strange as the AllowCopy properties on Trees 2 and 3 are set to True.
If you come up with a way to do this, that would be great! I will keep trying to get it to do what I need and will let you know if I have figured it out as well.
Thanks!!
Brenda
I have attached a sample that demonstrates how to copy and move nodes from different trees.
The sample is based on the following documentation:http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=6704
You mentioned before that you had the drag/drop functionality working without the DrawFilter implemented. Can you send me that as a sample? I attempted to remove the DrawFilter refererences and it still would not work.
Thank you, Michael!
I have a copy of that sample and used a lot of the concepts within it. I did, however, solve my issue. Using the original "UltraTreeDDSample" solution, I modified it to emulate my actual application (splitter containers, three UltraTree controls with only one Allowing Drop).
When I tried to "COPY" from UltraTrees 2 or 3, it would actually remove the nodes from these two trees and drop them on UltraTree1. That is not the functionality I wanted, so I had to figure out a way to drag nodes without moving them. I then created a Modular level DragNode that housed a clone of the node structure to be dragged (moving away from the SelectedNodesCollection that came with the DrawFilter Class). It works within UltraTree1 just fine - as a move, but when I would want to drag from UltraTrees 2 and 3, I would get an error stating I could not add a node that was already bound to an object. I switched the logic so every time I wanted to drag from Trees 2 or 3, the DragNode would become a NEW UltraTreeNode. However, this would limit the number of nodes to be dragged to only one at a time.
How I fixed my issue: I created a modular level NEW "virtual" UltraTree every time trees 2 or 3 would encounter a MouseMove. Within this event, I check to ensure the left mouse button was pressed, get the cursor position of the mouse relative to the control's coordinates, if the cursor was within the drag rectangle, then I instantiated the DragTree to a NEW UltraTree, looped through the tree's selected nodes collection, adding NEW UltraTreeNodes to the NEW UltraTree. I also established a modular level boolean to keep track of where the drag was coming from - UltraTree1 itself or Tree 2 or 3
Modified the DragDrop event for UltraTree1 to accomodate for the either the DragTree or the DragNode depending on where the drag was initiated. Works pretty slick. I have attached a copy of my additions.
Thanks!
Your welcome and thank you for using Infragistics