DragDrop 拖曳至TextBox

DragDrop 拖曳至TextBox

A

 

 

 


     private void textBox1_DragDrop(object sender, DragEventArgs e)
        {
            textBox1.Text = ((string[])e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
        }
        private void textBox1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                e.Effect = DragDropEffects.All;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }

 

 

拖曳檔案進去就會看到一個+的符號

b

 

 

image

 

 

檔案:drop_test.rar

參考資料

http://msdn.microsoft.com/en-us/library/system.windows.forms.dragdropeffects(v=vs.71).aspx

http://debut.cis.nctu.edu.tw/~ching/Course/AdvancedC++Course/__Page/ProgramTips/ProgramTech_DragDrop.html

 

 

 

 

大家一起加入blogads 賺零用錢!!