PC Review


Reply
Thread Tools Rate Thread

DragDrop files

 
 
Roger Uribe
Guest
Posts: n/a
 
      13th Aug 2004
It was easy in VB6...

how can i retrieve the name(s) of files dropped onto a vb.net control from
windows explorer

it'll be easy in vb.net too ... when i know the answer!!

thanks
roger


 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      14th Aug 2004
Roger,

An old sample that I made from a sample that is on MSDN

\\\Needs 2 textboxes on a form
Private MouseIsDown As Boolean = False
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.TextBox2.AllowDrop = True
End Sub
Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
MouseIsDown = True
Me.TextBox1.Cursor = Cursors.Hand
End Sub
Private Sub TextBox1_MouseMove(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseMove
If MouseIsDown Then
TextBox1.DoDragDrop(TextBox1.Text, DragDropEffects.Copy)
End If
MouseIsDown = False
Me.TextBox1.Cursor = Cursors.Default
End Sub
Private Sub TextBox2_DragEnter(ByVal sender As Object, ByVal e As _
System.Windows.Forms.DragEventArgs) Handles TextBox2.DragEnter
If (e.Data.GetDataPresent(DataFormats.Text)) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub TextBox2_DragDrop(ByVal sender As Object, ByVal e As _
System.Windows.Forms.DragEventArgs) Handles TextBox2.DragDrop
TextBox2.Text = e.Data.GetData(DataFormats.Text).ToString
End Sub
///

Some links
http://msdn.microsoft.com/library/de...ardSupport.asp

http://msdn.microsoft.com/library/de...mpdragdrop.asp

I hope this helps?

Cor


 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      15th Aug 2004
Roger,
Do you want the list of files or the text of the files?

It appears that Cor gave you a sample with the text of a file.

To get the list of files you need to use DataFormats.FileDrop instead of
DataFormats.Text:

Something like:

Private Sub TextBox2_DragDrop(ByVal sender As Object, ByVal e As _
System.Windows.Forms.DragEventArgs) Handles TextBox2.DragDrop
Dim files() As String
files = DirectCast(e.Data.GetData(DataFormats.FileDrop), String())
For Each file As String in files
TextBox2.Text &= file & ControlChars.CrLf
Next
End Sub

The DataFormats.FileDrop is an array of strings, where each element is the
file name that you are dropping from Windows Explorer.

Hope this helps
Jay

"Roger Uribe" <(E-Mail Removed)> wrote in message
news:cfjck0$5m2$(E-Mail Removed)...
> It was easy in VB6...
>
> how can i retrieve the name(s) of files dropped onto a vb.net control from
> windows explorer
>
> it'll be easy in vb.net too ... when i know the answer!!
>
> thanks
> roger
>
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      16th Aug 2004
Jay,

> It appears that Cor gave you a sample with the text of a file.


That why I gave the links with it, my idea was that this was easier to test.
Now I think I should have writen that in my text.

However your addition is a good one to make it complete.

Cor


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DragDrop files Peter Hemmingsen Microsoft C# .NET 0 6th Jun 2008 11:01 AM
DragDrop Meelis Microsoft C# .NET 3 13th Dec 2005 04:50 PM
dragdrop Frank Microsoft VB .NET 1 22nd Oct 2004 06:52 AM
Dragdrop with NTD Laurent Chevallier Microsoft Dot NET Framework Forms 3 16th Aug 2004 05:22 PM
passing on Control DragDrop to parent DragDrop Microsoft C# .NET 0 12th Dec 2003 08:24 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:05 PM.