Hi
i have an UltraTree(ver8.2) which is databound and displaying multiple columns using ViewStyle = Grid,but when i dragDrop a node ,there show me a error,the error message is "Cannot reposition a node from a bound nodes collection"
i set the AllowDrag = true.
there is my code(without drophightlight):
void UltraTreeX_SelectionDragStart(object sender, EventArgs e){ this.DoDragDrop(this.SelectedNodes, DragDropEffects.Move);}
void UltraTreeX_DragOver(object sender, DragEventArgs e){ System.Drawing.Point PointInTree; PointInTree = this.PointToClient(new Point(e.X, e.Y));
afterNode = this.GetNodeFromPoint(PointInTree); e.Effect = DragDropEffects.Move;}
void UltraTreeX_DragDrop(object sender, DragEventArgs e){ UltraTreeNode BeforeNode = null; SelectedNodesCollection SelectedNodes; UltraTreeNode DropNode = new UltraTreeNode();
SelectedNodes = (SelectedNodesCollection)e.Data.GetData(typeof(SelectedNodesCollection)); SelectedNodes = SelectedNodes.Clone() as SelectedNodesCollection; SelectedNodes.SortByPosition();
if (SelectedNodes[0].Level == afterNode.Level) { for (int i = 0; i <= (SelectedNodes.Count - 1); i++) { BeforeNode = SelectedNodes[i]; BeforeNode.Reposition(afterNode.Nodes); } } else if (SelectedNodes[0].Level > afterNode.Level) // { for (int i = 0; i <= (SelectedNodes.Count - 1); i++) { BeforeNode = SelectedNodes[i]; try { BeforeNode.Reposition(afterNode, NodePosition.Next); } catch (Exception ex) { MessageBox.Show(ex.Message); } -----> here } }}
thanks~
Hi,
The error message here is pretty clear. The tree does not support repositioning bound nodes. So you cannot do this if your tree is bound.
You can Submit a feature request to Infragistics and perhaps this feature can be added in a future release.
For now, there are a couple of things you could do:
1) Don't use the tree bound, but instead populate it manually.
2) Use a hidden column to sort the nodes and adjust the values in this hidden column such that the nodes are in the order you want.
Can you provide an example for option number 2? I've done that and I am able to change the underlying data, but I cannot make the Ultratree resort itlself without rebinding it.