将文本框拖放到列表框

时间:2017-09-09 16:56:38

标签: vb.net drag-and-drop mousedown

我正在编写一个VB.net(2015)代码,允许我从文本框拖放到列表框。

我已经设置了下面的代码,并将列表框中的允许下拉设置为true。

我可以将文本拖到列表框中,但它不会出现在列表框中。

看看下面的代码,我不确定我遗漏了什么,有什么建议或建议可以做什么?

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

0 个答案:

没有答案