I'm working on a VB.net(2015) code that would allow me to drag and drop from a text box to a list box.
I've set up the code below, and set the allow drop in the list box to true.
I’m able to drag the text to the list box, but it doesn’t appear in the list box.
Looking at the code below I’m not sure what piece I’ve left out, are there any recommendations or suggestions on what can be done?
Public Class PotluckParty
Private Sub enterFoodTextBox_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles enterFoodTextBox.MouseDown
enterFoodTextBox.DoDragDrop(enterFoodTextBox.Text, DragDropEffects.Move)
End Sub
Private Sub SaladListBox_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles SaladListBox.DragDrop
SaladListBox.Text &= e.Data.GetData(DataFormats.Text).ToString
enterFoodTextBox.Text = ""
End Sub
Private Sub SaladListBox_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles SaladListBox.DragEnter
If (e.Data.GetDataPresent(DataFormats.Text)) Then
e.Effect = DragDropEffects.Move
End If
End Sub