Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
844 views
in .NET FTP by (170 points)

Trying to use the MenuCreateItemDirectory to allow the user to copy the path name to the clip board:

 FtpRemoteFileList1.MenuItemCreateDirectory.Text = "Copy Path To Clipboard"
 AddHandler FtpRemoteFileList1.MenuItemCreateDirectory.Click, AddressOf MenuItemCreateDirectory_Click

 Private Sub MenuItemCreateDirectory_Click(sender As Object, e As EventArgs)

        Debug.WriteLine(FtpRemoteFileList1.CurrentDirectory & "/" & FtpRemoteFileList1.SelectedFileItems(0).Text)

 End Sub

i can't seem to find a way to cancel the event and a new folder is created. Is there any way to cancel this event and prevent the new folder from being created?

1 Answer

0 votes
by (51.6k points)
selected by
 
Best answer

I don't think it's possible to cancel the event.  You can add a new menu item as follows though:

FtpRemoteFileList1.Menu.MenuItems.Add("Copy Path To Clipboard")

and then add the handler to that item.

by (170 points)
Perfect.  Thank you.
by (2.7k points)
You should also be able to remove or hide any other menu items that you don't want.
by (170 points)
Already doing that. Can you swallow the double_click event?
by (51.6k points)
The only way to do that would be to extend the class as follows:

public class MyRemoteFileList : EnterpriseDT.Net.Ftp.Forms.FTPRemoteFileList
{
    protected override void fileListView_DoubleClick(object sender, EventArgs e)
    {
    }
}

and then use that instead of FTPRemoteFileList.  I haven't tried this so I can't promise that it'll work
by (170 points)
Again Perfect.  Thank you for the prompt responses.
by (170 points)
This works great if I don't want to do anything on the DoubleClick event.  If I have 2 forms in an application that both use the extended class is there a way to tell which one the _DoubleClick came from?  i looked through the sender properties but I could not find anything.    I want to use the DoubleClick event to do something other than transferring the file.  I suppose I could create 2 class extensions, one for each form.
by (51.6k points)
The sender should be the instance of the MyRemoteFileList class that the handler is attached to.
by (170 points)
Ugly solution, tag on the control hosting the instance:

   Protected Overrides Sub fileListView_DoubleClick(sender As Object, e As EventArgs)

        Select Case sender.parent.tag
            Case "Fix530"
                sender.parent.parent.parent.parent.parent.parent.parent.parent.controls(1).controls(0).controls(0).controls(2).text = DirectCast(sender, System.Windows.Forms.ListView).SelectedItems(0).Text
        End Select

    End Sub

Categories

...