|
-
Jun 2nd, 2008, 09:41 AM
#1
Thread Starter
Fanatic Member
[2008] creating FTP client. DRAG DROP operations.
Hey guys,
I am making a FTP client to be downloaded for free with the code available. However, I am have trouble creating a drag drop relation between the local file listbox and the remote file listbox.
The local filelistbox is a listbox , but is extended to give it a "browser dialog" feel.
The code project for this is http://www.codeproject.com/KB/select...esListBox.aspx
I tried all of the drag/drop event handlers, and for some reason none of them fire. My c# is weak so i think it might be something missing from the extended one. for example, in vb theres "MyBase.new" but I dont see anything like that in the c# version of it.
EDIT: I have converted the project to VB.NET and added mybase.new but it dosnt seem to do anything.
Last edited by masfenix; Jun 2nd, 2008 at 09:53 AM.
-
Jun 2nd, 2008, 12:29 PM
#2
Re: [2008] creating FTP client. DRAG DROP operations.
Here's an example on Drag and Drop functionallity between two listboxes containing strings:
VB.NET Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBox2.AllowDrop = True
End Sub
Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
ListBox1.DoDragDrop(ListBox1.SelectedItem, DragDropEffects.Copy Or DragDropEffects.Move)
End Sub
Private Sub ListBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragDrop
Dim droppedString As String = CType(e.Data.GetData("System.String"), String)
ListBox2.Items.Add(droppedString)
End Sub
Private Sub ListBox2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragEnter
If e.Data.GetDataPresent("System.String") Then
e.Effect = DragDropEffects.Copy
End If
End Sub
-
Jun 2nd, 2008, 02:22 PM
#3
Thread Starter
Fanatic Member
Re: [2008] creating FTP client. DRAG DROP operations.
Thankyou for the code,
I havnt tested it because i am at work, but a quick question. Will this allow multiple files to be selected and moved?
-
Jun 2nd, 2008, 02:45 PM
#4
Re: [2008] creating FTP client. DRAG DROP operations.
no, you'd have to pass an array of all the selected items to the DoDragDrop method instead of just one selected item as I'm doing. You'd then have to treat the data as an array in the DragDrop eventhandler.
-
Jun 2nd, 2008, 08:29 PM
#5
Thread Starter
Fanatic Member
Re: [2008] creating FTP client. DRAG DROP operations.
Alright thanks. But this raises a problem. Before I add the mousedown handler, i have the ability to select multiple files by dragging. But with the mousedown it just selects the file and goes into "move" mode.
anyway to fix that?
-
Jun 2nd, 2008, 08:40 PM
#6
Re: [2008] creating FTP client. DRAG DROP operations.
The system can't read your mind to know whether you're dragging to select or dragging to move. What you could do is require that the Alt key be depressed while dragging to select. You can then test for that in the MouseDown event handler and only start a drag-n-drop operation if it's not.
-
Jun 2nd, 2008, 08:43 PM
#7
Thread Starter
Fanatic Member
Re: [2008] creating FTP client. DRAG DROP operations.
Thankyou for the post. I was thinking of doing alternatives and whether its more usefull to select multiple files and click upload, or be able to select one file and upload.
however, I am still wondering how most FTP's applications do it? I understand they may use a low level language such as c but I am thinking, that this is something that should be able to be done in vb.
I will research it more, and if I do find a solution I will post it!@
-
Jun 2nd, 2008, 08:47 PM
#8
Re: [2008] creating FTP client. DRAG DROP operations.
Most FTP applications I've seen don't support drag and drop to move files. They have two lists of files, one local and one remote, with two buttons in between to move selected files in each direction. That's most appropriate I think because dragging and dropping is actually more trouble than clicking a button. It also means they won't try to drop on a folder that is not the one they currently have open, which is a good thing.
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
|