ciao!
ho attivato il drag&drop sun windows form.
però ho il problema che nella label, la lista di file viene duplicata.
in sostanza, se trascino un file, viene visualizzato due volte.
questo il codice:
codice:
private void Form1_Load(object sender, EventArgs e)
{
this.AllowDrop = true;
this.DragEnter += new DragEventHandler(Form1_DragEnter);
this.DragDrop += new DragEventHandler(Form1_DragDrop);
}
private void Form1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void Form1_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false);
foreach (string f in files)
{
this.label1.Text += f + "\n";
}
}
qualche idea?