namespace mouse_dragdrop
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_MouseMove(object sender, MouseEventArgs e)
{
if ((e.Button & MouseButtons.Left) == MouseButtons.Left)//判斷是否按下滑鼠左鍵
{
Cursor old_cursor = this.Cursor;
this.Cursor = new Cursor("arrow_l.cur");
DragDropEffects dropEffect = textBox1.DoDragDrop(textBox1.Text, DragDropEffects.Copy | DragDropEffects.Link);
this.Cursor = old_cursor;
}
}
private void textBox2_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Copy;//設定複製操作
}
private void textBox2_DragDrop(object sender, DragEventArgs e)
{
textBox2.Text = e.Data.GetData(DataFormats.Text).ToString();
}
}
}
不錯的文章
C# 基礎拖拉(drag & drop practicts)處理方式https://petereagle1.wordpress.com/2013/09/23/c-%E5%9F%BA%E7%A4%8E%E6%8B%96%E6%8B%89drag-drop-practicts%E8%99%95%E7%90%86%E6%96%B9%E5%BC%8F/
沒有留言:
張貼留言