Drag and drop
Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
4 posts
Page 1 of 1
Hello, i wanted to know how to drag and drop an item and listbox shows dropped file name(not the path, only name). Thanks.
Hello DarkyKnife,
First off welcome to the site cooll;
This code will allow you to drag-drop items into the listbox and show only the filename of each file. To make this code work you first need to select your "ListBox" control and change its "AllowDrop" propertie to 'True' and then add the following code.
First off welcome to the site cooll;
This code will allow you to drag-drop items into the listbox and show only the filename of each file. To make this code work you first need to select your "ListBox" control and change its "AllowDrop" propertie to 'True' and then add the following code.
Code: Select all
Hope that helps cooll;Private Sub ListBox1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
Private Sub ListBox1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragDrop
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
Dim draggedFiles As String() = CType(e.Data.GetData(DataFormats.FileDrop), String())
For Each filename As String In draggedFiles
ListBox1.Items.Add(FileIO.FileSystem.GetFileInfo(filename).Name)
Next
End If
End Sub
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
Hello CodenStuff,
I know this code was not sumbited for me but it did help alot !! Thanks,
Lewis
I know this code was not sumbited for me but it did help alot !! Thanks,
Lewis
Thank you very much, this helped me.
P.S. Very nice and usefull site with friendly people
P.S. Very nice and usefull site with friendly people

4 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023