|
-
Oct 20th, 2002, 03:00 PM
#1
Thread Starter
Lively Member
Drag and drop
Hi !
I try to write my first drag and drop program.
I would like to know what i need to do in order to catch drop of word/excel/ppt files.
Please send me some examples , or any other things that may help.
thanks.
P.S: i meant that i want to catch drop of files (outside) the form into the form.
I want to drap files from directorys like *.doc,*.xls,*.ppt, into any object that can present file imeges (but for now it's not so importent).
For now i just want to catch the file, and add the path of the file to some list (strings).
-
Oct 20th, 2002, 08:12 PM
#2
Hyperactive Member
This is an example for a multiline textbox :-
VB Code:
Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox1.DragDrop
If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
Dim filename As String() = e.Data.GetData(DataFormats.FileDrop)
MessageBox.Show(filename(0))
End If
End Sub
You must get the filename as a string array in case somebody is dragging multiple files and check thought them.
filename(0) will be a full path to the file so you can open it, analyse it's extension etc.
Oh for dragover effects you can check it with :-
VB Code:
If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
e.Effect = DragDropEffects.Move
End If
-
Oct 21st, 2002, 04:37 AM
#3
Thread Starter
Lively Member
problem
Do i need to enable sometrhing inorder the the D & D thing will work.
If i just add a textbox and your code , nothing happen !!
what i have forgot ?
-
Oct 21st, 2002, 02:01 PM
#4
Hyperactive Member
AllowDrop=true for the textbox or something like that.
I wrote an article a while back which might be of use to you in getting started with drag and drop:-
http://www.creativeprogrammers.com/a...drop-62-1.html
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|