Delay Auto-expand of nodes during drag drop

3 posts, 1 answers
  1. Amand
    Amand avatar
    9 posts
    Member since:
    Aug 2012

    Posted 09 Jul 2013 Link to this post

    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. Answer
    Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 11 Jul 2013 Link to this post

    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 >>

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Amand
    Amand avatar
    9 posts
    Member since:
    Aug 2012

    Posted 11 Jul 2013 Link to this post

    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.
Back to Top