小编Tos*_*eox的帖子

VB.NET DragAndDrop 不适用于控件

我正在尝试制作一个使用拖放功能的程序,但是,它仅在我将某些东西拖放到表单上时才起作用,而不是在控件上。如果我尝试使用控件,我只会得到“不可用”光标。

AllowDrop 属性在属性栏中设置,我也在表单加载时设置它。我不知道为什么我仍然不能放下东西;有没有人遇到过这个问题?

当前代码:

Public Class Main

Private Sub Main_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
    If e.Data.GetDataPresent("FileDrop", True) = True Then

        Dim Files() As String
        Dim i As Integer

        Files = e.Data.GetData(DataFormats.FileDrop)

        For i = 0 To Files.Length - 1
            FileList.Items.Add(Files(i))
        Next

    End If
End Sub

Private Sub Main_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter
    If e.Data.GetDataPresent(DataFormats.FileDrop) Then
        e.Effect = DragDropEffects.All
    End If
End Sub

Private Sub Main_Load(ByVal sender As Object, ByVal e …
Run Code Online (Sandbox Code Playgroud)

vb.net drag-and-drop

2
推荐指数
1
解决办法
8354
查看次数

标签 统计

drag-and-drop ×1

vb.net ×1