using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace AppDrag
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void listBox1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.All;
else
e.Effect = DragDropEffects.None;
}
private void listBox1_DragDrop(object sender, DragEventArgs e)
{
string[]s=(string[])e.Data.GetData(DataFormats.FileDrop,false);//GetData返回值为数组
for(int i=0;i<s.Length;i++)
listBox1.Items.Add(s[i]);
}
}
}
为应用提供文件的拖放功能
最新推荐文章于 2021-07-24 04:15:09 发布