|
-
Dec 5th, 2008, 12:44 PM
#1
Thread Starter
Addicted Member
[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
-
Dec 5th, 2008, 01:33 PM
#2
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
-
Dec 5th, 2008, 01:53 PM
#3
Fanatic Member
Re: [2005] Drag file onto form and have file name appear in text box
-
Dec 5th, 2008, 02:03 PM
#4
Thread Starter
Addicted Member
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.
-
Dec 5th, 2008, 03:42 PM
#5
Re: [2005] Drag file onto form and have file name appear in text box
 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.
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
|