C# listbox內容拖拽


 

  private void listBox1_MouseDown(object sender, MouseEventArgs e)
        {
            //調用DoDragDrop方法
            if (this.listBox1.SelectedItem != null)
            {
                this.listBox1.DoDragDrop(this.listBox1.SelectedItem, DragDropEffects.Copy);
            }
        }

 

            //設置treeview的AllowDrop屬性(允許放置屬性)為true
            this.treeView1.AllowDrop = true;

 

private void textBox1_DragEnter(object sender, DragEventArgs e)
        {
            //設置拖拽類型(這里是復制拖拽)
            e.Effect = DragDropEffects.Copy;
        }

        private void textBox1_DragDrop(object sender, DragEventArgs e)
        {
            //獲取值
            TableInfo item2 = (TableInfo)e.Data.GetData(typeof(TableInfo));
            this.textBox1.AppendText("\n");
                this.textBox1.AppendText(item2.TableName);
//            MessageBox.Show(item2.TableName);
        }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM