c#窗体支持多个文件拖放的代码实现
2010-08-02 13:21
330 查看
//在Form的属性中要设置 AlowDrop为true
private void Form1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetData(DataFormats.FileDrop) != null)
{
e.Effect = DragDropEffects.Copy;
}
//下面这段代码不支持间隔选中的文件
//if (e.Data.GetDataPresent(DataFormats.FileDrop))
// e.Effect = DragDropEffects.Link;
//else e.Effect = DragDropEffects.None;
}
private void Form1_DragDrop(object sender, DragEventArgs e)
{
String[] fileNames = (String[])e.Data.GetData(DataFormats.FileDrop);
int j = listBox1.Items.Count + 1;
for (int i = 0; i < fileNames.Length; i++)
{
listBox1.Items.Add(String.Format("{0:D3} ", i + j) + fileNames[i]);
}
//下面这段代码不支持间隔选中的文件
//string path = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
//listBox1.Items.Add(path);
}
private void Form1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetData(DataFormats.FileDrop) != null)
{
e.Effect = DragDropEffects.Copy;
}
//下面这段代码不支持间隔选中的文件
//if (e.Data.GetDataPresent(DataFormats.FileDrop))
// e.Effect = DragDropEffects.Link;
//else e.Effect = DragDropEffects.None;
}
private void Form1_DragDrop(object sender, DragEventArgs e)
{
String[] fileNames = (String[])e.Data.GetData(DataFormats.FileDrop);
int j = listBox1.Items.Count + 1;
for (int i = 0; i < fileNames.Length; i++)
{
listBox1.Items.Add(String.Format("{0:D3} ", i + j) + fileNames[i]);
}
//下面这段代码不支持间隔选中的文件
//string path = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
//listBox1.Items.Add(path);
}
相关文章推荐
- C#窗体支持多个文件拖放的代码实现
- 几行代码帮您实现Win7窗体的打开效果(C#)
- C#实现拖放获取文件路径
- [代码]Delphi实现获取文件及文件夹大小(支持超过2G的大文件)
- c#中实现文件拖放打开的方法
- C#.net实现windows窗体程序对Excel文件的读写操作
- 也发一个自己实现的android简单文件选择器代码。支持多卡,排序
- 为什么C++编译器不支持模板头文件和实现代码分离的编译
- C#实现http协议支持上传下载文件的GET、POST请求
- C#代码实现上传文件到SharePoint文档库
- asp.net(c#)文件下载实现代码
- c#实现复制全部文件夹及文件的代码
- C#读取文件MD5值的实现代码
- c#中实现文件拖放打开的方法
- C#中ListView控件实现窗体代码
- c#实现word,excel转pdf代码及部分Office 2007文件格式转换为xps和pdf代码整理
- C#中实现文件拖放打开的方法
- 为什么C++编译器不支持模板头文件和实现代码分离的编译
- 用C#用C#实现窗体在规定时间弹出,例如:10:00.弹出后关闭。并在5分钟后再次弹出。5次后停止。最好有具体代码实现窗体在规定时间弹出,例如:10:00.弹出后关闭。并在5分钟后再次弹出。5次后停止。最好有具体代码
- 在winfrom下利用c#代码,实现kindEditor的JavaScript方法:editor.html(),实现上报窗体的自动提交。