I'm trying to drag and drop some random selected text from a random webpage within Firefox onto a textbox in my Winform application, but for some reason I can't get it to work. I have set AllowDrop to true on the control(textbox) and I'm handling the events DragEnter and DragDrop, so that's not the problem. Anyone know what the problem could be?
My code looks like this:
public Form1()
{
InitializeComponent();
tbISBN.DragDrop += new DragEventHandler(tbISBN_DragDrop);
tbISBN.DragEnter += new DragEventHandler(tbISBN_DragEnter);
tbISBN.AllowDrop = true;
}
void tbISBN_DragEnter(object sender, DragEventArgs e)
{
foreach (var param in e.Data.GetFormats())
Console.WriteLine(param);
if ((e.AllowedEffect & DragDropEffects.All) != 0 && e.Data.GetDataPresent(typeof(string)))
{
e.Effect = DragDropEffects.All;
}
}
void tbISBN_DragDrop(object sender, DragEventArgs e)
{
string stringData = e.Data.GetData(typeof(string)) as string;
MessageBox.Show(stringData);
}