This is a migrated thread and some comments may be shown as answers.

How to re drag and drop events of RadTreeView

6 Answers 175 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
yulin
Top achievements
Rank 1
yulin asked on 06 Sep 2016, 08:25 AM
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.

6 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 06 Sep 2016, 08:38 AM
Hello Yulin,

Thank you for writing.  

RadTreeView handles the whole drag and 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.
0
yulin
Top achievements
Rank 1
answered on 07 Sep 2016, 01:55 AM

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

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 09 Sep 2016, 10:13 AM
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.
0
yulin
Top achievements
Rank 1
answered on 10 Sep 2016, 11:36 AM

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 

0
yulin
Top achievements
Rank 1
answered on 11 Sep 2016, 08:52 AM

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

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Sep 2016, 12:46 PM
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.
Tags
Treeview
Asked by
yulin
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
yulin
Top achievements
Rank 1
Share this question
or