조회 수 14364 댓글 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
번호 분류 제목 날짜 조회 수 추천 수
176 LINUX 내 .bashrc 설정 secret 2015.08.31 0 0
175 일반 VP9 코덱 2015.09.01 7872 0
174 C# TreeView의 rootnode(TreeNode)에서 하위 항목 찾기 2015.09.21 15298 0
173 C# ArrayList를 string[] 배열로 변환하는 방법 2015.09.23 13286 0
172 PHP 파일 데이터 저장하고 불러오기(파일 입출력) 2015.09.30 8923 0
171 LINUX 커맨드라인에서 url 접근 - wget 사용법 2015.09.30 12385 0
170 LINUX 리눅스 부팅시 명령스크립트 실행하기 2015.09.30 10741 0
169 LINUX 리눅스 시스템 시작시에 자동 실행할 파일 등록하기 2015.09.30 10460 0
168 Pi ftp 설정하기 2015.10.01 7533 0
167 Pi 무선랜 wifi 설정 2015.10.01 7280 0
166 Pi ftp 포트 변경하기 2015.10.01 10279 0
165 C# List<T> 사용법 2015.10.13 49291 0
164 JAVA 현재시간 구하기 2015.10.21 8247 0
163 JAVA 텍스트 파일 읽기, 쓰기 2015.10.21 13344 0
162 일반 Html에서 사용하는 contentType의 종류 2015.10.27 9565 0
목록
Board Pagination ‹ Prev 1 ... 18 19 20 21 22 23 24 25 26 27 ... 34 Next ›
/ 34

나눔글꼴 설치 안내


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

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

설치 취소

Designed by sketchbooks.co.kr / sketchbook5 board skin

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5