2012年6月2日 星期六
ListBox1 拖放
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ListBox1.AllowDrop = True
Me.ListBox2.AllowDrop = True
Me.ListBox1.Items.Add("1")
Me.ListBox1.Items.Add("2")
End Sub
Private Sub ListBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
If Me.ListBox1.SelectedIndex >= 0 Then
Me.ListBox1.DoDragDrop(Me.ListBox1.SelectedItem.ToString, DragDropEffects.Copy)
End If
End Sub
Private Sub ListBox2_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragEnter
e.Effect = DragDropEffects.Copy
End Sub
Private Sub ListBox2_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragDrop
If e.Data.GetDataPresent(DataFormats.Text) Then
Me.ListBox2.Items.Add(e.Data.GetData(DataFormats.Text))
End If
End Sub
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言