LarryZ
asked on
VB.Net move Items from ListBox to Textboxes
I have a listbox, populated with 5 items from a database. I wan't to drag items, one at a time, to 5 textboxes.
Here is my code for the source listbox:
Private Sub ListBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.Mouse EventArgs) Handles ListBox2.MouseDown
ListBox2.DoDragDrop(ListBo x2.Selecte dValue.ToS tring, DragDropEffects.Move)
End Sub
Here is code for one of the destination textboxes:
Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragE ventArgs) Handles TextBox1.DragDrop
TextBox1.AppendText(e.Data .GetData(D ataFormats .StringFor mat))
End Sub
Private Sub TextBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragE ventArgs) Handles TextBox1.DragEnter
TextBox1.Text = e.Data.GetData(DataFormats .StringFor mat)
End Sub
The destination textboxes all have AllowDrop set to True.
If I try to move an item from the listbox, it gets copied instead (item appears in textbox but does not disappear from listbox)
Here is my code for the source listbox:
Private Sub ListBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.Mouse
ListBox2.DoDragDrop(ListBo
End Sub
Here is code for one of the destination textboxes:
Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragE
TextBox1.AppendText(e.Data
End Sub
Private Sub TextBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragE
TextBox1.Text = e.Data.GetData(DataFormats
End Sub
The destination textboxes all have AllowDrop set to True.
If I try to move an item from the listbox, it gets copied instead (item appears in textbox but does not disappear from listbox)
ASKER
Evidently, it has nothing to do with BindingSource. I populated another ListBox manually. Drag and Copy works OK, But Drag and Move has two quirks. Only the first item dragged off ListBox appears in TextBox. After that, no more can be dragged. Also, the first item dragged still remains in ListBox.
Microsoft's example for this is pretty bloated and difficult to utilize. Any easy ways to do this?
Microsoft's example for this is pretty bloated and difficult to utilize. Any easy ways to do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hope this helps somewhat. I don't know how to handle it.