I am trying to adapt this code but in my form it doesnt seem to trigger the event
any suggestions
vb Code:
private void listBox1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
// make sure they're actually dropping files (not text or anything else)
if( e.Data.GetDataPresent(DataFormats.FileDrop, false) == true )
// allow them to continue
// (without this, the cursor stays a "NO" symbol
e.Effect = DragDropEffects.All;
}
private void listBox1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
// transfer the filenames to a string array
// (yes, everything to the left of the "=" can be put in the
// foreach loop in place of "files", but this is easier to understand.)
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
// loop through the string array, adding each filename to the ListBox
foreach( string file in files )
{
listBox1.Items.Add(file);
}
}