๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ‘จ๐Ÿผ‍๐Ÿ’ป๊ฐœ๋ฐœ/C#

C# - ๋“œ๋ž˜๊ทธ ์•ค ๋“œ๋กญ(Drag & Drop)

by Janger 2022. 10. 9.
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
๋ฐ˜์‘ํ˜•