标签:
1.AllowDrop属性要设置为True
2.C#代码参考一下写法
#region dgvResult_DragDrop 拖拽完成时,读取文件名全路径 /// <summary> /// 拖拽完成时,读取文件名全路径 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvResult_DragDrop(object sender, DragEventArgs e) { //文件路径+文件名 label1.Text =
((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString(); } #endregion #region dgvResult_DragEnter 拖拽时,文件类型可用 /// <summary> /// 拖拽时,文件类型可用 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvResult_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None; } #endregion
标签:
原文地址:http://www.cnblogs.com/puxian/p/4976267.html