List view, folder and subitem destination with drag and drop

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions 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.
3 posts Page 1 of 1
Contributors
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

Hello i have a listview, i want to make so when i drag a folder it adds the folders name in listviews first column which is folder name, and then it adds the full path to the first subitem destination, i know how to drag and drop but not how i can do this
Last edited by AnoPem on Sun Apr 15, 2012 6:00 pm, edited 1 time in total.
https://t.me/pump_upp
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

You could use this:
Code: Select all
    Private Sub ListView1_DragDrop(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles ListView1.DragDrop
        Dim paths As String() = e.Data.GetData(DataFormats.FileDrop)
        For i As Integer = 0 To paths.Length - 1

            Dim foldername As String = Path.GetFileName(paths(i))
            ListView1.Items.Add(New ListViewItem(New String() {foldername, paths(i)}))
        Next

    End Sub
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

mandai wrote:
You could use this:
Code: Select all
    Private Sub ListView1_DragDrop(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles ListView1.DragDrop
        Dim paths As String() = e.Data.GetData(DataFormats.FileDrop)
        For i As Integer = 0 To paths.Length - 1

            Dim foldername As String = Path.GetFileName(paths(i))
            ListView1.Items.Add(New ListViewItem(New String() {foldername, paths(i)}))
        Next

    End Sub
Thank you work as it should cooll;
https://t.me/pump_upp
3 posts Page 1 of 1
Return to “Coding Help & Support”