I'm trying to drag and drop some text from a webpage to a textbox on a Winform. All works as expected from MS Edge, Firefox Opera and Chrome but not IE11 or Safari. The brief code I am using on the DragOver event is:
private void textBox1_DragDrop(object sender, DragEventArgs e)
{
if(e.Data.GetDataPresent(DataFormats.Text, false))
{
textBox1.Text = (string)e.Data.GetData(DataFormats.Text);
}
}
It seems like the DataFormat from IE and Safari is not Text, but I can't figure out what it is.
Of course, it might be a browser thing not letting me drag text out.
Any ideas what's causing my issue?
Thanks,
J.
This is a way to get the data in all available formats from a Drag&Drop operation.
A Browser source works fine (I tested Edge, IE 11 and FireFox).
The Source formats are usually passed as strings or as a
MemoryStream
.You can further adapt it to your context.
UPDATE:
Rebuilt the main Class object. It's now more compact and handles more details. Also, I've added a sample VS sample
WinForms
Form to test its results. It's a standard Form that can be included in a VS Project.Google Drive: Drag & Drop sample Form