txtDataTarget、txtSource)txtDataTarget.AllowDrop = true
private void txtDataTarget_DragDrop(object sender, DragEventArgs e) {
txtDataTarget.Text = e.Data.GetData(DataFormats.Text).ToString();
}
private void txtDataTarget_DragEnter(object sender, DragEventArgs e) {
e.Effect = DragDropEffects.Copy; // 顯示複製圖標
}
private void txtSource_MouseMove(object sender, MouseEventArgs e) {
if ((e.Button & MouseButtons.Left) == MouseButtons.Left) {
string reportPath = Application.StartupPath.Substring(0,
Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\"));
reportPath += @"\sl3293dwarro.cur";
Cursor MyNoDropCursor = new Cursor(reportPath);
DragDropEffects dropEffect = this.txtSource.DoDragDrop(this.txtSource.Text,
DragDropEffects.Copy | DragDropEffects.Link);
}
}
關鍵點:
AllowDrop 啟用放置目標DragEnter 設定 e.Effect 回饋視覺提示DoDragDrop 發起拖放,指定資料與允許效果