码迷,mamicode.com
首页 > Windows程序 > 详细

C# winform文件拖放相关

时间:2015-01-30 15:30:29      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:

winform实现拖放功能需要先对控件的AllowDrog属性设置为true技术分享

 在控件的DragEnter事件捕获拖放的文件列表

定义全局变量string[] filesPath=null;

filesPath=(string[])e.Data.GetData(DataFormats.FileDrop);

//文件拖放完成时执行的方法

void DrogComplete(Control ctrl)

{

Rectangle rect = new Rectangle(PointToScreen(ctrl.Location), ctrl.Size);
if (rect.Contains(MousePosition))
{
//遍历拖放的文件
foreach (string item in filesPath)
{
//执行对拖放的文件的操作
}
}

}

C# winform文件拖放相关

标签:

原文地址:http://www.cnblogs.com/lvdong-1986/p/4262240.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!