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~