C# WinForm의 AllowDrop이 동작하지 않는 경우 해결 방법. (How to fix WinForm's AllowDrop …
페이지 정보
본문
안녕하세요. 엔지엠소프트웨어입니다. 윈폼을 개발하다가 AllowDrop 속성을 True로 설정해도 파일이 드롭되지 않는 경우가 있습니다. 여러가지 문제점을 하나씩 풀어나가야 합니다. 아래 검토 내용을 확인해보고 테스트 해보세요^^
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.AllowDrop = true;
this.DragDrop += Form1_DragDrop;
this.DragEnter += Form1_DragEnter;
}
DragEnter 이벤트를 아래와 같이 설정해야 합니다. 핵심은 e.Effect = DragDropEffects.Copy; 입니다.
private void Form1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
마지막으로 Visual Studio 또는 프로그램이 관리자 권한으로 실행중인지 확인해보세요. 관리자 권한으로 실행된 프로그램은 드래그 드롭을 수행할 수 없습니다.
추천0 비추천0
- 이전글[ActiveMQ] jolokia-agent: No access restrictor found at classpath:/jolokia-access.xml, access to all MBeans is allowed 20.11.11
- 다음글EADDRNOTAVAIL (101): Address not available 20.11.07
댓글목록
등록된 댓글이 없습니다.