Weird problem - hoping somebody can help me with it. Trying to do a simple drag and drop inside a UltraTree. Here is my sample tree - taken from a sample
groupTree.Nodes.Add("Continent:North America", "North America");groupTree.Nodes.Add("Continent:South America", "South America");groupTree.Nodes.Add("Continent:Antarctica", "Antarctica");groupTree.Nodes.Add("Continent:Europe", "Europe");groupTree.Nodes.Add("Continent:Asia", "Asia");
When I drag North America into South America both nodes disappear!!! But when I drag South America into North America code works just fine - in other words it seems to work when dragging down but not up.
Below is my Drop routine.
private void groupTree_DragDrop(object sender, DragEventArgs e) { Point pt = ((UltraTree)sender).PointToClient(new Point(e.X, e.Y)); UltraTreeNode DestinationNode = ((UltraTree)sender).GetNodeFromPoint(pt); if (e.Data.GetDataPresent("Infragistics.Win.UltraWinTree.SelectedNodesCollection", false)) { SelectedNodesCollection selectedNodes = (SelectedNodesCollection)e.Data.GetData(typeof(SelectedNodesCollection)); selectedNodes = selectedNodes.Clone() as SelectedNodesCollection; //Sort the selected nodes into their visible position. //This is done so that they stay in the same order when //they are repositioned. selectedNodes.SortByPosition(); for (int i = 0; i <= (selectedNodes.Count - 1); i++) { UltraTreeNode aNode = selectedNodes[i]; aNode.Reposition(DestinationNode.Nodes); } } groupTree.Invalidate(); }
Lev said:Nodes don't completely disappear when you use Reposition function but they are scrolled up out of the view.
Ok - I think I figured it out. Nodes don't completely disappear when you use Reposition function but they are scrolled up out of the view. If you want to see them again you have to use up arrow to scroll up to reveal disappeared nodes. Still looks like a bug but at least i can find a workaround.
Here is a simple project I put together to demonstrate - please don't use UltraTree Drag and Drop sample as it has too much extraneous stuff going on.
Here is the entire Form. Drag 'Hello' into 'Hello1' and notice that both Hello and Hello1 now disappeared from the view - you have to use up arrow to scroll up to reveal them again.
public partial class Form1 : Form { public Form1() { InitializeComponent(); ultraTree1.Override.SelectionType = Infragistics.Win.UltraWinTree.SelectType.ExtendedAutoDrag; ultraTree1.Nodes.Add("Hello"); ultraTree1.Nodes.Add("Hello1"); ultraTree1.Nodes.Add("Hello2"); ultraTree1.Nodes.Add("Hello3"); ultraTree1.Nodes.Add("Hello4"); ultraTree1.Nodes.Add("Hello5"); } private void ultraTree1_DragDrop(object sender, DragEventArgs e) { Point pt = ((UltraTree)sender).PointToClient(new Point(e.X, e.Y)); UltraTreeNode destinationNode = ((UltraTree)sender).GetNodeFromPoint(pt); if (e.Data.GetDataPresent("Infragistics.Win.UltraWinTree.SelectedNodesCollection", false)) { SelectedNodesCollection selectedNodes = (SelectedNodesCollection)e.Data.GetData(typeof(SelectedNodesCollection)); SelectedNodesCollection selectedNodes2 = selectedNodes.Clone() as SelectedNodesCollection; //selectedNodes2.SortByPosition(); for (int i = 0; i <= (selectedNodes2.Count - 1); i++) { UltraTreeNode aNode = selectedNodes2[i]; aNode.Reposition(destinationNode.Nodes); } } } private void ultraTree1_DragEnter(object sender, DragEventArgs e) { e.Effect = DragDropEffects.All; } private void ultraTree1_SelectionDragStart(object sender, EventArgs e) { ultraTree1.DoDragDrop(ultraTree1.SelectedNodes, DragDropEffects.Move); } }
I was not able to reproduce the probelm you described here after replacing the contents of the 'UltraTree1_DragDrop' method (in the UltraTree Drag and Drop sample) with the code you posted here. If pssible please post the entire modified project so we can take a closer look. Note that it is possible that whatever problem you are having is being caused by a bug that has been fixed in a later version than the one you are using.