Header Banner
wonderhowto.mark.png
Gadget Hacks Next Reality Food Hacks Null Byte The Secret Yumiverse Invisiverse Macgyverisms Mind Hacks Mad Science Lock Picking Driverless

How to Create a Drag Drop with ListBox Using VB.Net

Nov 9, 2014 07:44 AM
Nov 9, 2014 04:11 PM
Camera lens on a white background.

Hello guys, today I wanna share how to create a drag and drop with listbox using VB.net. Just copy and paste the following code under public class.

Private Sub ListBox1_DragEnter(ByVal sender As Object, ByVal e As

System.Windows.Forms.DragEventArgs) Handles ListBox1.DragEnter

If e.Data.GetDataPresent(DataFormats.FileDrop) Then

e.Effect = DragDropEffects.All

End If

End Sub

Private Sub ListBox1_DragDrop(ByVal sender As Object, ByVal e As

System.Windows.Forms.DragEventArgs) Handles ListBox1.DragDrop

If e.Data.GetDataPresent(DataFormats.FileDrop) Then

Dim MyFiles() As String

Dim i As Integer

' Assign the files to an array.

MyFiles = e.Data.GetData(DataFormats.FileDrop)

' Loop through the array and add the files to the list.

For i = 0 To MyFiles.Length - 1

ListBox1.Items.Add(MyFiles(i))

Next

End If

End Sub

Then In order for all the maic drag and drop to occur or happen ?

Just Go to the property bar of the ListBox And Change Allow Drop From FALSE TO TRUE

AllowDrop:True

This is a video to help you out ....

The next big software update for iPhone is coming sometime in April and will include a Food section in Apple News+, an easy-to-miss new Ambient Music app, Priority Notifications thanks to Apple Intelligence, and updates to apps like Mail, Photos, Podcasts, and Safari. See what else is coming to your iPhone with the iOS 18.4 update.

Related Articles

Comments

No Comments Exist

Be the first, drop a comment!