DragDrop files from Windows Explorer

6 posts, 1 answers
  1. Joe
    Joe avatar
    8 posts
    Member since:
    Apr 2009

    Posted 20 Nov 2009 Link to this post

    Hi,

    I'm creating an application that will allow users to drag and drop files from Windows explorer into a RadTreeView.  I have been unable to highlight a node as a drop target when a file is dragged over it.  Is this possible?

    Ideally I would like to determine which node the user is hovering over when dragging the file, hightlight the node and change the drop icon to either an allow or disallow icon depending on the node tag.

    Many thanks,

    Joe
  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 23 Nov 2009 Link to this post

    Hello Joe,

    You can determine which node is under your cursor with the following MouseMove handler:
    private void radTreeView1_MouseMove(object sender, MouseEventArgs e)
    {
        RadElement elementAtPoint = radTreeView1.ElementTree.GetElementAtPoint(e.Location);
        if (elementAtPoint is TreeNodeUI)
        {
            TreeNodeUI nodeUI = (elementAtPoint as TreeNodeUI);
            nodeUI.BorderColor = Color.Red;
            RadTreeNode node = nodeUI.AssociatedTreeNode;
            // Handle conditions based on node.Tag.
        }
    }

    Please note however that you will have to revert the border color to the previous value when the mouse moves over a new node. Write again if you need further assistance.

    Regards,
    Victor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Joe
    Joe avatar
    8 posts
    Member since:
    Apr 2009

    Posted 23 Nov 2009 Link to this post

    Hi Victor,

    Thanks for the response. 

    I would like to mimic/fake a node mouseover in order to highlight the node in exactly the same way it is highlighted when a use moves the mouse over a tree node.  Is this possible?

    Thanks,

    Joe
  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 23 Nov 2009 Link to this post

    Hello Joe,

    Thank you for the question. This is possible, you just need to set the appropriate settings. Currently, for a hovered node, they are:
    nodeUI.BackColor = Color.FromArgb(255, 231, 162);
    nodeUI.NumberOfColors = 1;
    nodeUI.BorderColor = Color.FromArgb(255, 189, 105);

    Please note that these settings are applicable to TreeNodeUI type, not RadTreeNode. Also these are the settings from the ControlDefault theme. If you are using a different theme and you would like to determine the settings you can do so with the Visual Style Builder tool or with the aid of RadControlSpy tool.

    Please write again if you need further assistance.

    Best wishes,
    Victor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Joe
    Joe avatar
    8 posts
    Member since:
    Apr 2009

    Posted 23 Nov 2009 Link to this post

    Hi Victor,

    That works great, thank you :)

    Joe
  7. Answer
    Victor
    Admin
    Victor avatar
    1351 posts

    Posted 23 Nov 2009 Link to this post

    You are welcome, Joe! Feel free to mark this thread as answered.
    If you need further assistance we are ready to assist you.

     
    Sincerely yours,
    Victor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
UI for WinForms is Visual Studio 2017 Ready