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.
Boris Toromanov"] Hi bmw, 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.
Well, I have incorporated the UltraTreeDrawFilter class to assist me with drawing lines between nodes, etc. and assigned it to my UltraTree as the DrawFilter. However, the moment I start dragging, my UltraTree simply disappears from view.
Any ideas as to why that would happen?
bmw (getting frustrated)
Hello bwm,
Is it possible for you to send attach a sample that demonstrates the UltraTree disappearing?
Please let me know if you have any questions.
Actually, it would not be possible to attach a sample as it is very big. However, this is what I have. I needed three TreeViews. Two that would house information that the user will be allowed to Drag to the one UltraTree that represents the hierarchy of a report. In order for all three TreeViews to be sizeable, and the user to know which Tree represented what information, this is what I did.
I placed a SplitContainer on my form as Dock = Fill and BackColor = Transparent. In Panel 1, I placed an UltraGroupBox with the main UltraTree that allows dragging and dropping inside of it as Dock = Fill. In Panel 2, I placed yet another SpitControl to house the other two trees inside of their own UltraGroupBox. The sizing for all three works great this way!!
I discovered that setting the main SplitContainer BackColor = Transparent is what was causing my issue as I was performing the actual drag. Set this to a standard color and it works just fine now.
Thank you all so much!!!
Brenda
Hello Brenda,
Your welcome.
Michael,
Thank you again for pointing me in the right direction regarding the draw filter class. Works great. I have another question.
I have a total of 3 UltraTreeViews. The first being the Main treeview and the other two display what's available (disabling nodes that already exist in the first treeview). Before implementing the drawfilter class, I was able to drag from the two treeviews onto the Main treeview. Now that I have the class implemented, the Main treeview does not recognize a drag/drop from the other two treeviews. I changed up the SelectionDragStart events on the other two treeviews to begin (DoDragDrop) the drop on the "SelectedNodes".
Any Ideas? How would I incorporate these two treeviews and have them work with the Main treeview and the drawfilter class?
Thanks, again!
Your welcome and thank you for using Infragistics
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!
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.
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!!
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.