Easily implement the control room

zhaozj2021-02-16  41

In Vb.NET, you can implement the Trust between Listbox, first to make the allowDrop property of the control of the tutoring data to be true. Then the processes are the trust effect, and the allowedeffect is the action effect of setting the source control of the hosted source, and the Effect is the action of setting the target control. These stuff can be found in Drageventargs Members!

Private Sub Form1_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim i As Int32 For i = 0 To 9 ListBox1.Items.Add ( "Item" & i) Next ListBox2.AllowDrop = True End Sub

Private Sub ListBox1_MouseDown (ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown Dim itemIndex As Integer itemIndex = ListBox1.IndexFromPoint (eX, eY) If itemIndex> = 0 Then ListBox1.DoDragDrop (ListBox1. Items (itemindex), Dragdropeffects.copy End If End Sub

Private Sub ListBox2_DragEnter (ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragEnter If (e.Data.GetDataPresent (DataFormats.Text)) Then e.Effect = DragDropEffects.Copy Else e.Effect = Dragdropeffects.none end if End Sub

Private Sub ListBox2_DragDrop (ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragDrop Dim sItem As String sItem = e.Data.GetData (DataFormats.Text) .ToString ListBox2.Items.Add (sItem) Listbox1.items.removeat (listbox1.findstring (sitem)) End Sub

转载请注明原文地址:https://www.9cbs.com/read-27504.html

New Post(0)