Drag & Drop - RadBrowseEditor

4 posts, 1 answers
  1. Samantha
    Samantha avatar
    21 posts
    Member since:
    Apr 2009

    Posted 13 Sep 2013 Link to this post

    Is it possible to drag and drop a document to this control, instead of having to navigate to the document?  I have changed the "Allow Drop" property to true, but nothing changed.
  2. Answer
    Dess
    Admin
    Dess avatar
    1609 posts

    Posted 18 Sep 2013 Link to this post

    Hello Samantha,

    Thank you for your contacting Telerik Support.

    In order to achieve drag and drop functionality of RadBrowseEditor, please, have a look at the following code snippet:
    public partial class Form1 : Form
    {
        string draggedFileName = string.Empty;
     
        public Form1()
        {
            InitializeComponent();
     
            this.radBrowseEditor1.AllowDrop = true;
            this.radBrowseEditor1.DragEnter += radBrowseEditor1_DragEnter;
            this.radBrowseEditor1.DragDrop+=radBrowseEditor1_DragDrop;
        }
     
        private void radBrowseEditor1_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Effect== DragDropEffects.Move)
            {
                this.radBrowseEditor1.Value = draggedFileName;
                e.Effect = DragDropEffects.None;
            }
        }
     
        private void radBrowseEditor1_DragEnter(object sender, DragEventArgs e)
        {
            Array data = ((IDataObject)e.Data).GetData("FileName") as Array;
            if (data != null)
            {
                if ((data.Length == 1) && (data.GetValue(0) is String))
                {
                    string filename = ((string[])data)[0];
                    string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
                    string ext = Path.GetExtension(filename).ToLower();
                    if ((ext == ".doc") || (ext == ".docx"))
                        // here you can restrict allowed files for drag & drop operation
                    {
                        e.Effect = DragDropEffects.Move;
                        draggedFileName = files[0];
                    }
                }
            }
        }
    }

    Please, find the attached video (drag and drop over the browser to play), demonstrating the implemented behaviour.

    I hope this information helps. Should you have further questions, I would be glad to help.

    Regards,
    Desislava
    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. Samantha
    Samantha avatar
    21 posts
    Member since:
    Apr 2009

    Posted 19 Sep 2013 Link to this post

    It works like a dream - thank you kindly!
  5. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 24 Sep 2013 Link to this post

    Hello Samantha,

    I am glad that the issue you were facing is now resolved. Please do not hesitate to contact us if you have any additional questions.

    It was pleasure for me to assist you.

    Regards,
    Desislava
    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 >>
Back to Top