Results 1 to 4 of 4

Thread: Drag and drop

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    92

    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).

  2. #2
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    Dublin, Ireland
    Posts
    262
    This is an example for a multiline textbox :-

    VB Code:
    1. Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox1.DragDrop
    2.     If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
    3.            Dim filename As String() = e.Data.GetData(DataFormats.FileDrop)
    4.            MessageBox.Show(filename(0))
    5.     End If
    6. 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:
    1. If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
    2.     e.Effect = DragDropEffects.Move
    3. End If

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    92

    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 ?

  4. #4
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    Dublin, Ireland
    Posts
    262
    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
  •  



Click Here to Expand Forum to Full Width