Results 1 to 5 of 5

Thread: [2005] Drag file onto form and have file name appear in text box

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2008
    Posts
    163

    [2005] Drag file onto form and have file name appear in text box

    EDIT:
    I want to make a simple program to check the files crc to a crc in the file name.

    I've changed what I'd like to do with this project. I'd like to be able to select multiple files then drag and drop them into a list box. From there I'm going to run the files through a cmd line crc program to get their crc checksums. Then finally compare the crc in the file name to the crc returned by the crc program. Then show if the file passes or fails the check.
    Last edited by pball_inuyasha; Dec 5th, 2008 at 01:27 PM. Reason: Changed whole concept of program

  2. #2
    Frenzied Member MaximilianMayrhofer's Avatar
    Join Date
    Aug 2007
    Location
    IM IN YR LOOP
    Posts
    2,001

    Re: [2005] Drag file onto form and have file name appear in text box

    Set AllowDrop on your form to true, then use this:

    Code:
    Public Class Form1
        Private Sub Form1_DragEnter( _
            ByVal sender As System.Object, _
            ByVal e As System.Windows.Forms.DragEventArgs _
        ) Handles MyBase.DragEnter
            If e.Data.GetDataPresent(DataFormats.FileDrop) Then _
                e.Effect = DragDropEffects.All
        End Sub
    
        Private Sub Form1_DragDrop( _
            ByVal sender As System.Object, _
            ByVal e As System.Windows.Forms.DragEventArgs _
        ) Handles MyBase.DragDrop
            If e.Data.GetDataPresent(DataFormats.FileDrop) Then _
                ListBox1.Items.AddRange(DirectCast(e.Data.GetData(DataFormats.FileDrop), String()))
        End Sub
    End Class

  3. #3
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    515

    Re: [2005] Drag file onto form and have file name appear in text box

    subscribing

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Nov 2008
    Posts
    163

    Re: [2005] Drag file onto form and have file name appear in text box

    Thanks MaximilianMayrhofer that works great.

    Just one more question for now how can I remove multiple selected lines in the listbox. I've played with ListBox1.Items.RemoveAt(ListBox1.SelectedIndex) and other similar .selected things.

    Also how hard would it be to use the del key to del selected item instead of using a button on the form?

    Also how can I get the text from a list box line by line. I'm going to have file names dragged into the list box. Then I need to set them in a string that is filename1 filename2 etc. Just a space in between each file name. This is going to be part of the parameters needed to run the cmd line crc checker.

    Which reminds me, I have no clue how to run a program with parameter in vb.

    here is how i currently run the program.
    Code:
                Dim info As New System.Diagnostics.ProcessStartInfo(fsum)
                info.WindowStyle = ProcessWindowStyle.Minimized
                Dim proc As Process = Process.Start(info)
                proc.EnableRaisingEvents = True
                AddHandler proc.Exited, AddressOf ProcessExited
    with fsum as the program name
    Last edited by pball_inuyasha; Dec 5th, 2008 at 02:33 PM.

  5. #5
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: [2005] Drag file onto form and have file name appear in text box

    Quote Originally Posted by pball_inuyasha
    Thanks MaximilianMayrhofer that works great.

    Just one more question for now how can I remove multiple selected lines in the listbox. I've played with ListBox1.Items.RemoveAt(ListBox1.SelectedIndex) and other similar .selected things.

    Also how hard would it be to use the del key to del selected item instead of using a button on the form?

    Also how can I get the text from a list box line by line. I'm going to have file names dragged into the list box. Then I need to set them in a string that is filename1 filename2 etc. Just a space in between each file name. This is going to be part of the parameters needed to run the cmd line crc checker.

    Which reminds me, I have no clue how to run a program with parameter in vb.

    here is how i currently run the program.
    Code:
                Dim info As New System.Diagnostics.ProcessStartInfo(fsum)
                info.WindowStyle = ProcessWindowStyle.Minimized
                Dim proc As Process = Process.Start(info)
                proc.EnableRaisingEvents = True
                AddHandler proc.Exited, AddressOf ProcessExited
    with fsum as the program name
    Use the Listboxes SelectedIndicies collection to get the indicies of the selected items to actually remove those items.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

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