Drag and Drop Windows Forms C#
Описание
Simple programme for processing multiple files quickly in C# Source code below:::::::::
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace Drag_AndDrop
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void listBox1_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false);
foreach (string file in files)
{
listBox1.Items.Add(file);
//THEN DO WHATEVER YOU WANT TO EACH file in files
//e.g.
}
}
private void listBox1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop, false) == true)
{
e.Effect = DragDropEffects.All;
}
}
}
}
Рекомендуемые видео



















