设置窗体的AllowDrop=True;
private void Form1_DragEnter(object sender, DragEventArgs e) {
if (e.Data.GetDataPresent( DataFormats.Text ))
e.Effect = DragDropEffects.Link;
else
e.Effect = DragDropEffects.None;
}
private void Form1_DragDrop(object sender, DragEventArgs e) {
try {
this.textBox1.Text = ((System.Array)e.Data.GetData( DataFormats.FileDrop )).GetValue( 0 ).ToString();
} catch { }
}
if (e.Data.GetDataPresent( DataFormats.Text ))
e.Effect = DragDropEffects.Link;
else
e.Effect = DragDropEffects.None;
}
private void Form1_DragDrop(object sender, DragEventArgs e) {
try {
this.textBox1.Text = ((System.Array)e.Data.GetData( DataFormats.FileDrop )).GetValue( 0 ).ToString();
} catch { }
}