void Form2_DragDrop(object sender, DragEventArgs e)
label1.Text = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
void Form2_DragEnter(object sender, DragEventArgs e)
if (e.Data.GetDataPresent(DataFormats.FileDrop))
DragDropEffects.Link;
else e.Effect = DragDropEffects.None;
The designer hides all the D+D properties and events for the RTB. Not sure why, it works fine if I set them in code:
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
richTextBox1.AllowDrop = true;
richTextBox1.DragEnter += richTextBox1_DragEnter;
richTextBox1.DragDrop += richTextBox1_DragDrop;
}
private void richTextBox1_DragEnter(object sender, DragEventArgs e) {
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Link;
else e.Effect = DragDropEffects.None;
}
private void richTextBox1_DragDrop(object sender, DragEventArgs e) {
richTextBox1.Text += ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
}
}