Ric*_*ram 6 vb.net url drag-and-drop spotify
如果有人将Spotify轨迹从spotify桌面应用程序拖放到Excel,则Excel会显示歌曲的艺术家和标题.
我有一个winforms应用程序,我想在其中做同样的事情.如果我拖放到这样的列表框....
Private Sub ListBox1_DragEnter(sender As Object, e As DragEventArgs) Handles ListBox1.DragEnter
ListBox1.Items.Add(e.Data.GetData(DataFormats.Text))
End sub
Run Code Online (Sandbox Code Playgroud)
....所有它曾经做过,是显示spotify轨道ID.由于Excel不是为读取Spotify网址而设计的,因此数据必须位于拖放中.但无论我选择哪种数据格式,我都只能获得ID.
小智 0
Private Sub lstQueue_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles lstQueue.MouseDown
If (e.Button = MouseButtons.Right) Then
'clear previous selection
lstQueue.SelectedItems.Clear()
'highlight selected item
lstQueue.SelectedIndex = lstQueue.IndexFromPoint(e.X, e.Y)
'initiate movedown event for drag/drop
Dim ix As Integer = lstQueue.IndexFromPoint(e.Location)
If ix <> -1 Then
lstQueue.DoDragDrop(ix.ToString, DragDropEffects.Move)
End If
End If
End Sub
Private Sub lstQueue_DragEnter(sender As Object, e As DragEventArgs) Handles lstQueue.DragEnter
'make label visile for drag/drop
lblMoveLine.Visible = True
End Sub
Private Sub lstQueue_DragOver(ByVal sender As Object, ByVal e As DragEventArgs) Handles lstQueue.DragOver
'allow drag over for drag/drop
If e.Data.GetDataPresent(DataFormats.Text) Then
e.Effect = DragDropEffects.Move
Dim index = lstQueue.IndexFromPoint(lstQueue.PointToClient(New Point(e.X, e.Y)))
lblMoveLine.Top = (index - lstQueue.TopIndex) * lstQueue.ItemHeight
End If
End Sub
Private Sub lstQueue_DragLeave(sender As Object, e As System.EventArgs) Handles lstQueue.DragLeave
'hide label for drag/drop
lblMoveLine.Visible = False
End Sub
Private Sub lstQueue_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles lstQueue.DragDrop
'remove item and add in new location
If e.Data.GetDataPresent(DataFormats.Text) Then
Dim dix As Integer = CInt(e.Data.GetData(DataFormats.Text))
Dim ix As Integer = lstQueue.IndexFromPoint(lstQueue.PointToClient(New Point(e.X, e.Y)))
If ix <> -1 Then
Dim obj As Object = lstQueue.Items(dix)
lstQueue.Items.Remove(obj)
lstQueue.Items.Insert(ix, obj)
lstQueue.SelectedIndex = ix
End If
End If
lblMoveLine.Visible = False
End Sub
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
99 次 |
| 最近记录: |