当前位置:首页 > 开发 > C# > 正文内容

C# Winform 拖放文件

C#4个月前 (12-23)
private void Form1_Load(object sender, EventArgs e)
{
    this.AllowDrop = true;
    this.DragEnter += Form_DragEnter;
    this.DragDrop += Form0_DragDrop;
}

private void Form_DragEnter(object sender, DragEventArgs e)
{
    if (e.Data.GetDataPresent(DataFormats.FileDrop))
    {
		e.Effect = DragDropEffects.Copy;
    }
    else
    {
		e.Effect = DragDropEffects.None;
    }
}
private void Form0_DragDrop(object sender, DragEventArgs e)
{
    string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
    foreach (string file in files)
    {
		Console.WriteLine(file);
    }
}


转载请注明出处。

本文链接:http://pythonopen.com/?id=1625

相关文章

C# 可空参数

using System; using System.Runtime.Inte...

C# BackgroundWorker,在DoWork里更新控件内容

一般情况下不可以直接在BackgroundWorker的DoWork事件中更新 UI 控件在Back...

C# Graphics图像抗锯齿

g.SmoothingMode = SmoothingMode.AntiAlia...

C# using与多重using

1. using 语句概述在 C# 中,using 语句主要用于确保实现了 IDisposable...

C# i++和++i的区别

核心区别操作顺序            ...