Advanced Drag & 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.
2 posts
Page 1 of 1
Hey Guys i need your help...
I made myself a pretty nice App Launcher which fades in and out on the center top of my screen and some mouse over and leave effect and runs every app perfektly BUT I need your explanation for some drag and drop stuff.
1. I want the lancher accept drop and drop files on it and launch them
2. Files should appear with their icon
3. Mouse hover effetcs
i need a explanation for that to understand why am i using the code and for what am i using it so i can get i to work as i want...
and do i need a combobox - richtextbox or whatever to drop my files into?
some kind of tutorial would be nice =)
best regards skAi
I made myself a pretty nice App Launcher which fades in and out on the center top of my screen and some mouse over and leave effect and runs every app perfektly BUT I need your explanation for some drag and drop stuff.
1. I want the lancher accept drop and drop files on it and launch them
2. Files should appear with their icon
3. Mouse hover effetcs
i need a explanation for that to understand why am i using the code and for what am i using it so i can get i to work as i want...
and do i need a combobox - richtextbox or whatever to drop my files into?
some kind of tutorial would be nice =)
best regards skAi
You could use a ListView with an ImageList for this.
Here is a basic example that will add each dragged file to a list, set an icon, and ask if the file should be launched:
Here is a basic example that will add each dragged file to a list, set an icon, and ask if the file should be launched:
Code: Select all
The mouse hover effects or DragDropEffects are used to tell the source program what to do with the dragged data. Dim icons As ImageList = New ImageList()
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
ListView1.AllowDrop = True 'allow DragDrop events in the ListView
icons.ImageSize = New Size(32, 32) 'set the display sizes
ListView1.LargeImageList = icons
ListView1.View = View.LargeIcon
End Sub
Private Sub ListView1_DragDrop(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles ListView1.DragDrop
Dim filedropped As Boolean = e.Data.GetDataPresent(DataFormats.FileDrop)
If filedropped Then
icons.Images.Clear()
ListView1.Items.Clear()
Dim files As Array = e.Data.GetData(DataFormats.FileDrop)
For i As Integer = 0 To files.Length - 1
Dim path As String = files(i).ToString()
Dim ico As Icon
Try
ico = Icon.ExtractAssociatedIcon(path)
Catch ex As Exception
ico = Me.Icon
End Try
icons.Images.Add(ico)
Dim lvi As ListViewItem = New ListViewItem()
lvi.Text = path
lvi.ImageIndex = i
ListView1.Items.Add(lvi)
Dim dr As DialogResult = MessageBox.Show("Start " & path & "?", "", MessageBoxButtons.YesNo)
If dr = DialogResult.Yes Then
Process.Start(path)
End If
Next
End If
End Sub
Private Sub ListView1_DragEnter(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles ListView1.DragEnter
e.Effect = DragDropEffects.All
End Sub
2 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023