Hi all, I'm doing really badly on my first try at a drag and drop. I'm trying to have a listBox that can have a file dragged onto it from Windows Explorer
From the very simple example here -
http://support.microsoft.com/kb/307966 I have
Set AllowDrop on the list to TRUE
Set the event DragDrop
Set the event DragEnter
I have the following code
private void listFilesToConvert_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
// DEBUG
MessageBox.Show("DragEnter");
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.All;
else
e.Effect = DragDropEffects.None;
}
private void listFilesToConvert_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
// DEBUG
MessageBox.Show("DragDrop");
string[] s = (string[])e.Data.GetData(DataFormats.FileDrop);
int i;
for (i = 0; i < s.Length; i++)
listFilesToConvert.Items.Add(s[i]);
}
I can't say I understand it all, but it looks very similar to other code on the net. It's probably something simple but I can't work it out.
Neither debug message boxes fire.
Cheers
Graham R