TextBox的 textBox1.AllowDrop = true;
private void label2_MouseDown(object sender, MouseEventArgs e)
{
Label lab = (Label)sender;
lab.DoDragDrop(lab.Text, DragDropEffects.Copy);
}
private void textBox1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(String)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void textBox1_DragDrop(object sender, DragEventArgs e)
{
((TextBox)sender).Text = e.Data.GetData("System.String", true).ToString();
}