Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Drag and Drop files/folders from explorer and display in listbox

Total Hit ( 4132)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


This code will show you how simple it is to get file/folder list dragged from explorer.

Step-By-Step Example

- Create a Windows Application
- Add one ListBox control on the form
- Add the following code in form1
- Run the project and try to drag and drop some files into listbox from explore

Click here to copy the following block
Private Sub Form1_Load(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles MyBase.Load

  '//This will allow listbox to receive item drop event
  ListBox1.AllowDrop = True
End Sub

Private Sub ListBox1_DragEnter(ByVal sender As Object, _
      ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragEnter
  '//check the format of item being dragged, we only want FileDrop format
  If e.Data.GetDataPresent(DataFormats.FileDrop) Then
    e.Effect = DragDropEffects.Copy
  Else
    e.Effect = DragDropEffects.None
  End If
End Sub

Private Sub ListBox1_DragDrop(ByVal sender As Object, _
      ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragDrop

  Dim strFiles() As String
  Dim i As Long

  '//get list of dragged files/folders
  strFiles = e.Data.GetData(DataFormats.FileDrop)

  For i = 0 To strFiles.GetUpperBound(0)
    ListBox1.Items.Add(strFiles(i))
  Next
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.