๐จ๐ผ๐ป๊ฐ๋ฐ/C#
C# - ๋๋๊ทธ ์ค ๋๋กญ(Drag & Drop)
Janger
2022. 10. 9. 00:59
728x90
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
this.AllowDrop = true;
this.DragEnter += new DragEventHandler(Form1_DragEnter);
this.DragDrop += new DragEventHandler(Form1_DragDrop);
}
void Form1_DragEnter(object sender, DragEventArgs e) {
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
}
void Form1_DragDrop(object sender, DragEventArgs e) {
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files) Console.WriteLine(file);
}
}
์ถ์ฒ:
https://stackoverflow.com/questions/68598/how-do-i-drag-and-drop-files-into-an-application
How do I drag and drop files into an application?
I've seen this done in Borland's Turbo C++ environment, but I'm not sure how to go about it for a C# application I'm working on. Are there best practices or gotchas to look out for?
stackoverflow.com
728x90