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
精彩评论