블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2731)
Unity3D (814)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (57)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (51)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
03-29 00:00

'드래그&드롭'에 해당되는 글 1건

  1. 2010.06.30 파일 드래그&드롭 1

먼저 데이터를 받을 폼이나 콘트롤의 AllowDrop 프로퍼티를 True 로 합니다.

그런 다음 DragEnter Event에서 데이터를 확인하시고

DragDrop event에서 실제 처리를 하시면 됩니다.

 

이 예제는 다른 프로그램에서 파일을 드래그해서 리스트에 떨구면 파일을 추가하는 예제입니다.

 

        private void listBox1_DragEnter(object sender, DragEventArgs e)
        {
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    e.Effect = DragDropEffects.Copy;
                }
                else
                {
                    e.Effect = DragDropEffects.None;
                }
        }

        private void listBox1_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop, false))
                {
                    string[] fileNames = (string[])e.Data.GetData(DataFormats.FileDrop);
                    foreach (string fileName in fileNames)
                    {

                        // 여기서 기타 파일에 대한 처리를 해주시면 됩니다.
                        listBox1.Items.Add(fileName);
                    }
                }
            }
            catch (System.Exception ex)
            {
                //예외
            }
        }

출처 : http://www.devpia.com/MAEUL/Contents/Detail.aspx?BoardID=17&MAEULNo=8&no=95686&ref=95686

반응형

'Programming > C#' 카테고리의 다른 글

Singleton  (0) 2010.07.02
창크기 조절 막기  (0) 2010.07.02
Form-Form 데이터 전달  (0) 2010.06.29
.NET CF에서 WndProc 사용법  (0) 2010.06.29
C# 주의해야 할 문법(dispose,using,close)  (2) 2010.06.28
Posted by blueasa
, |