在想要拖拉(Drag-and-Drop)的控制項上textBox1

的MouseDown的事件寫

textBox1.DoDragDrop(textBox1.Text,DragDropEffects.Copy|DragDropEffects.Move);

 

然後再想要拖拉過去的控制項textBox2寫的DragEnter事件寫

if(e.Data.GetDataPresent(DataFormats.Text)))

{

     e.Effect=DragDropEffects.Copy;

}

接著在textBox2的DragDrop事件寫

textBox2.Text=(string)e.Data.GetData(DataFormats.Text);

 

 

arrow
arrow
    全站熱搜

    welkingunther 發表在 痞客邦 留言(0) 人氣()