Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
130
how to drag node under databound ultratree with grid
posted

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~

 

Parents
  • 469350
    Suggested Answer
    Offline posted

    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.

Reply Children
No Data