조회 수 14368 댓글 1
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print
특정 컨트롤에서 Drag&Drop 으로 파일을 받으려면 우선 해당 컨트롤의 AllowDrop 옵션을 True로 설정.

이후 컨트롤의 DragOver 와 DragDrop 이벤트 핸들러를 작성.

 

 

// Drag & Drop
private void OnFileDragDrop(object sender, DragEventArgs drgevent)
{
    Console.WriteLine("Error in AppendData procedure.");
    //textFilePath.Text = "Drag Drop";

    //base.OnDragDrop(drgevent);

    try
    {
        if (drgevent.Data.GetDataPresent(DataFormats.FileDrop, false))
        {
            string[] fileNames = (string[])drgevent.Data.GetData(DataFormats.FileDrop);

            //foreach (string fileName in fileNames)
            {
                //파일 처리
                pLogSession.sFilename = fileNames[0];
            }
        }
    }
    catch (System.Exception ex)
    {
        //예외처리
        Console.WriteLine(ex.Message);
    }
}

private void OnFileDragEnter(object sender, DragEventArgs e)
{
    Console.WriteLine("Target Form Drag Enter");

    e.Data.GetDataPresent(typeof(System.String));

    //e.Effect = DragDropEffects.All;
    e.Effect = DragDropEffects.Copy;
}

  • Dreamy 2012.11.29 15:19

    폼에서 탐색기로 파일을 끌고가고 싶을 때는,

     

      public partial class Form1 : Form { 
        public Form1() { 
          InitializeComponent(); 
          this.MouseDown += Form1_MouseDown; 
        } 
        private void Form1_MouseDown(object sender, MouseEventArgs e) { 
          string[] files = new string[] { @"c:\temp\test.txt" }; 
          this.DoDragDrop(new DataObject(DataFormats.FileDrop, files), DragDropEffects.Copy); 
        } 
      } 


Dreamy의 코드 스크랩

내가 모으고 내가 보는

List of Articles
번호 분류 제목 날짜 조회 수 추천 수
401 LINUX [Shell Script] 쉘 프로그래밍을 위한 명령어 file 2015.04.30 7648 0
400 Android git archive 를 사용해서 폴더를 .git 제외하고 tar 나 zip 으로 묶기 1 2019.02.10 7721 0
399 Android JNI에서 가변 인수(varargs) 쓰기 2014.08.04 7774 0
398 LINUX 리눅스 계정 목록 보기 2016.03.21 7819 0
397 LINUX 우분투(Ubuntu)에서 APM 웹서버 구축하기 2016.03.17 7867 0
396 일반 VP9 코덱 2015.09.01 7873 0
395 Pi Simple DAC - PWM을 Voltage로 변환하는 회로 file 2016.11.21 7897 0
394 Android gdb commands 2015.03.11 7989 0
393 Pi ARDUINO multi function shield 핀정보 및 FND 소스 2016.11.21 8031 0
392 PHP Simple GD example 2014.07.10 8097 0
391 JAVA 자바 프로그래머가 알아야할 10가지 이클립스 단축키 1 2015.10.27 8126 0
390 Pi 라즈베리파이 적외선(IR) 리모컨 송신/수신 - LIRC Library 2017.10.17 8132 0
389 일반 NirCmd 사용법 2015.12.08 8225 0
388 JAVA 현재시간 구하기 2015.10.21 8248 0
387 LINUX 우분투 root 계정 사용하기 2014.06.18 8400 0
목록
Board Pagination ‹ Prev 1 ... 3 4 5 6 7 8 9 10 11 12 ... 34 Next ›
/ 34

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소

Designed by sketchbooks.co.kr / sketchbook5 board skin

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5