开发者

Drag and drop items from listbox to desktop

开发者 https://www.devze.com 2023-03-20 09:02 出处:网络
I have a ListBox control, that contains a few items that display attachments (files or directories). I have successfully allowed users to drag and drop items from their desktop to the ListBox , but I

I have a ListBox control, that contains a few items that display attachments (files or directories).

I have successfully allowed users to drag and drop items from their desktop to the ListBox , but I have not b开发者_高级运维een able to allow the user to drag and drop items from the ListBox to their desktop.

Is this possible?


Hope this helps you get started (assuming list box is just a list of files with their full paths):

Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles ListBox1.MouseDown
  Dim fileList As New Collections.Specialized.StringCollection
  fileList.Add(ListBox1.SelectedItem.ToString)

  Dim dataObj As New DataObject
  dataObj.SetFileDropList(fileList)

  ListBox1.DoDragDrop(dataObj, DragDropEffects.Copy)
End Sub
0

精彩评论

暂无评论...
验证码 换一张
取 消