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

Delay Auto-expand of nodes during drag drop

2 Answers 184 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Amand
Top achievements
Rank 1
Amand asked on 09 Jul 2013, 10:09 AM
Hi Telerik support,

IWhen using drag-drop in the treeview, there is an auto expand behaviour to be able to move a node inside another. Currently, the time required on a node to exapand it is very short. Is it possible to modify this time to expand the node only after a longer time.

I found a post to disable this behaviour (http://www.telerik.com/community/forums/winforms/treeview/prevent-auto-expand-of-nodes-during-drag-and-drop.aspx) but not to modify the delay.

Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 11 Jul 2013, 01:50 PM
Hello Amand,

Thank you for writing.

The are a few steps to delay the node expanding:
  1. Create a timer and attach an event handler for the tick event to it.
  2. Set the timer Interval property to the desired delay time.
  3. Handle the RadTreeView DragOverNode and NodeExpandedChanging events.
  4. Create a bool variable and initialize it to false.
  5. Create a RadTreeNode object to store the node which we will expand later.
  6. Set the created variable to true in the DragOverNode event handler.
  7. In the NodeExpandedChanging event handler check the variable and if its value is true cancel the default behavior, start the timer and set our bool variable to false.
  8. The last step is implement the timer tick event handler. In it we just need to expand the current node and stop the timer.

I have attached a sample project which implements the described logic.

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>

0
Amand
Top achievements
Rank 1
answered on 11 Jul 2013, 03:51 PM
Dimitar,

Thanks for the answer.
I may try this, but doing all the auto-expand seems quite complicated, dealing with all the cases, some of these you did not address in your example (move to other nodes, stopping, doing the drop, ...).
Anyway, that's a good lead, I'll keep you posted if I have further questions.

Regards.
Tags
Treeview
Asked by
Amand
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Amand
Top achievements
Rank 1
Share this question
or