How to re drag and drop events of RadTreeView

7 posts, 1 answers
  1. yulin
    yulin avatar
    4 posts
    Member since:
    Sep 2016

    Posted 06 Sep Link to this post

    Hello,
      I have a problem when useing the RadTreeView,I want to drag a RadTreeView Nodes to another RadTreeView,but I don't want to remove the RadTreeView Node ,and when dragenter I want out of a dialog box to choose the Node's Childs,then add the childs to another Radtreeviw.
  2. Answer
    Dess
    Admin
    Dess avatar
    1609 posts

    Posted 06 Sep Link to this post

    Hello Yulin,

    Thank you for writing.  

    RadTreeView handles the whole drag and drop operation by its TreeViewDragDropService. The PreviewDragOver event allows you to control on what targets the node being dragged can be dropped on. The PreviewDragDrop event allows you to get a handle on all the aspects of the drag and drop operation, the source (drag) control, the destination (target) control, as well as the node being dragged. This is where we will initiate the actual physical move of the node(s) from one tree view to the target control. The following help article is quite useful  for customizing the service: http://docs.telerik.com/devtools/winforms/treeview/drag-and-drop/modify-the-dragdropservice-behavior

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. yulin
    yulin avatar
    4 posts
    Member since:
    Sep 2016

    Posted 06 Sep in reply to Dess Link to this post

    Hi Dess,
    Thankyou so much for your quick response.

    PS :I found that Text's RadTreeNode and Value are sometimes unbalanced in the display, such as Text='abc'
    Value='123', when I change the value value is, the interface will display the value of the value ,not text
    Regards,

    yulin

  5. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 09 Sep Link to this post

    Hello Yulin, 

    Thank you for writing back. 

    I am glad that the provided information was useful for your case.

    Note that by default, when RadTreeView is in unbound mode, modifying the Text or the Value property of a node will automatically update the other one. This behavior can be controlled via the EditMode property of the TreeViewElement. Additional information is available here: http://docs.telerik.com/devtools/winforms/treeview/editing/editing-nodes

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  6. yulin
    yulin avatar
    4 posts
    Member since:
    Sep 2016

    Posted 10 Sep Link to this post

    Hi Dess,

    Thank you for your response.

    When I change the Node's Value like this 

     if (dbcontext.SaveChanges() > 0)
                            {
                               
                                ContextMenuRadTree.SelectedNode.Text = diag.DIAG_Name;
                                if (ContextMenuRadTree.SelectedNode.Value == null)
                                {
                                    
                                    ContextMenuRadTree.SelectedNode.Value = diag.DIS_ID;
                                }
                            }

     Interface is shown as ContextMenuRadTree.SelectedNode.Value not   ContextMenuRadTree.SelectedNode.Text 

  7. yulin
    yulin avatar
    4 posts
    Member since:
    Sep 2016

    Posted 11 Sep in reply to Dess Link to this post

    Hi Dess ,

    Thank you so much for your response.

    Now, I add New Node into RadTreeView like this

                            RadTreeNode rtn = new RadTreeNode();
                            rtn.Name = q.Ques_ID.ToString();
                            rtn.Text = q.Ques_Content;
                            rtn.Value = q.Ques_Index;
                            radtv_Question.Nodes.Add(rtn);

    then, I want to change the Node's index  like this 

     RadTreeNode NodeToUp = radtv_Question.SelectedNode;
                if (NodeToUp.PrevNode != null)
                {
                    RadTreeNode NodeToDown = NodeToUp.PrevNode;
                    int upId = Convert.ToInt32(NodeToUp.Name);
                    int upIndex = Convert.ToInt32(NodeToUp.Value);
                    int downId = Convert.ToInt32(NodeToDown.Name);
                    int downIndex = Convert.ToInt32(NodeToDown.Value);

    if (dbcontext.UPDATEQUESTIONINDEX(upId, downIndex) > 0 && dbcontext.UPDATEQUESTIONINDEX(downId, upIndex) > 0)
                        {
                            radtv_Question.AllowEdit = true;
                            radtv_Question.BeginEdit();
                            RadTreeNode NewNode = new RadTreeNode();
                            NewNode = (RadTreeNode)NodeToUp.Clone();
                            NewNode.Value = downIndex;
                            NodeToDown.Value = upIndex;
                            radtv_Question.Nodes.Insert(NodeToDown.Index, NewNode);
                            NodeToUp.Remove();
                            radtv_Question.SelectedNode = NewNode;
                            radtv_Question.EndEdit();
                        }

    }

    but  the NodeToDown text   is "0".

    yulin

  8. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 13 Sep Link to this post

    Hello Yulin, 

    Thank you for writing back. 

    By default, the TreeViewElement.EditMode property is set to TextAndValue. Hence, when you update the RadTreeNode.Value property, the Text property will be updated as well.

    There are three available options for the EditMode property:

    Value - When the user performs edit, the Value will be edited.

    Text - When the user performs edit, the Text will be edited.

    TextAndValue - When the user performs edit, both the Text and the will be edited.

    Feel free to use this option which suits your requirement best.
     
    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready