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

Drag & Drop - RadBrowseEditor

3 Answers 77 Views
BrowseEditor
This is a migrated thread and some comments may be shown as answers.
Samantha
Top achievements
Rank 1
Samantha asked on 13 Sep 2013, 07:23 PM
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.

3 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Sep 2013, 12:26 PM
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 >>
0
Samantha
Top achievements
Rank 1
answered on 19 Sep 2013, 01:32 PM
It works like a dream - thank you kindly!
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Sep 2013, 12:57 PM
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 >>
Tags
BrowseEditor
Asked by
Samantha
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Samantha
Top achievements
Rank 1
Share this question
or