DragDrop events not firing

8 posts, 0 answers
  1. almir
    almir avatar
    7 posts
    Member since:
    Sep 2007

    Posted 08 Sep 2007 Link to this post

    hi,

    following events are not firing DragDrop, DragOver, DragEnter you will find the code below but it is trivial, all of this events are inhereted from microsoft components but still i would like them to fire.

    Anyhow what I need is to check if i can drop node-draged to the one below and I need an event and possibility to change cursor or something like this. Is there a way for doing that ?

    thanks

      radTreeView1.DragDrop += new DragEventHandler(radTreeView1_DragDrop);
                radTreeView1.DragEnter += new DragEventHandler(radTreeView1_DragEnter);
                radTreeView1.DragOver += new DragEventHandler(radTreeView1_DragOver);
      

    void radTreeView1_DragDrop(object sender, DragEventArgs e)
            {
                Console.WriteLine("dragdrop ");
            }

            void radTreeView1_DragOver(object sender, DragEventArgs e)
            {
                Console.WriteLine("drag over");
            }

            void radTreeView1_DragEnter(object sender, DragEventArgs e)
            {
                Console.WriteLine("drag enter");

            }



  2. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 10 Sep 2007 Link to this post

    Hi almir,

    The events that you mention are not supported, because they do not provide enough information on the action performed. You can use the DragEnding and DragEnded events instead of the DragDrop event.

    The DragEnding event args also provide the direction (where the node is to be dropped) and allow to cancel the drag and drop operation. If I understand correctly what you want ti achieve, the DragEnding event is the one you need.

    Unfortunately RadTreeView currently does not provide an "over" event, but we will be glad to work with you towards a more complete drag and drop infrastructure. Could you please share with us more details about your scenario?
    Specifically we need more information about how you intend to use an "over" event.

    It should be noted that RadTreeView currently supports drag and drop operations with other RadTreeView controls. We can even support drag and drop operations with any RadControl, if there is demand for this feature.

    Thank you for your cooperation.
     

    All the best,
    Jordan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. almir
    almir avatar
    7 posts
    Member since:
    Sep 2007

    Posted 10 Sep 2007 Link to this post

    Hi,
    what do you mean by "because they do not provide enough information on the action performed",  as much as I can remmber this events provide right place for giving visual feedback about drop destination.

    my intended scenario is to cancel drag, which i can do now on drop-ending, however I can do it only after user already droped the node  (released the mouse). What I would like to achive is to give visual feedback to user, during draging (i think best place would be on over event) so that he can see that it is not allowed to drop the node here on this node. If you have some other idea how to achive this please give me a hint.

    However much more important scenario for me would be, to be able to drag lines from RadGrid on the items in the tree (like draging files into new folders in windows-explorer) where I could handle the event same way like in nodes on tree

    thanks for fast response
    almir
  5. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 12 Sep 2007 Link to this post

    Hi almir,

    What I meant was that the drag&drop-related events in Windows Forms do not provide RadTreeView specific information like the node being dragged, or the target node.

    To provide visual feedback while dragging you could use the NodeMouseEnter or NodeMouseHover events of RadTreeView.

    As for your second scenario, you could try to write some custom logic in order to "convert" a RadGridView row to a RadTreeView node.
     

    Greetings,
    Jordan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. almir
    almir avatar
    7 posts
    Member since:
    Sep 2007

    Posted 12 Sep 2007 Link to this post

    Hi i will try this first scenario out for my visual feedback.

    second scenario sounds good, but I have no idea where to start or how to do that, wher and how could i convert RadGridViewRow to TreeNode ?? pleas could you provide som link, how to or code snippet

    thanks
  7. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 12 Sep 2007 Link to this post

    Hi almir,

    You could try implementing drag and drop from RadGridView to RadTreeView using Windows Forms drag and drop functionality. The following code shows the handlers of the events needed to implement simple drag and drop between a TextBox and RadTreeView:

    void radTreeView1_DragDrop(object sender, DragEventArgs e) 
            { 
                Point p = this.radTreeView1.PointToClient(new Point(e.X, e.Y)); 
                RadTreeNode hoveredNode = this.radTreeView1.GetNodeAt(p.X, p.Y); 
                 
                if (hoveredNode == null
                { 
                    return
                } 
     
                hoveredNode.Nodes.Add(e.Data.GetData(DataFormats.Text).ToString()); 
            } 
     
            void radTreeView1_DragEnter(object sender, DragEventArgs e) 
            { 
                if (e.Data.GetDataPresent(DataFormats.Text)) 
                { 
                    e.Effect = DragDropEffects.Copy; 
                } 
                else 
                { 
                    e.Effect = DragDropEffects.None; 
                } 
            } 
     
            void textBox1_MouseDown(object sender, MouseEventArgs e) 
            { 
                if (string.IsNullOrEmpty(this.textBox1.Text)) 
                { 
                    return
                } 
     
                this.textBox1.DoDragDrop(this.textBox1.Text,  
                    DragDropEffects.Copy | DragDropEffects.Move); 
            } 

    This should get you started.

     
    Kind regards,
    Jordan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Nino
    Nino avatar
    9 posts
    Member since:
    Apr 2013

    Posted 23 May 2013 Link to this post

    Hi Guys, 

    any idea why my treeview do not rise the DragEnded event? 
    DragEnding works ok ...

    Thanks

    Nino
  9. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 28 May 2013 Link to this post

    Hi,

    Thank you for writing.

    Currently, there is an issue preventing the event from firing. However, I am glad to inform you that the issue is is already resolved in our development branch and It will be included in our next release, which is expected in the middle of June.

    I hope this time frame is suitable for you.
     
    Regards,
    Stefan
    Telerik
    RadChart for WinForms is obsolete. Now what?
Back to Top
UI for WinForms is Visual Studio 2017 Ready