tags:

views:

376

answers:

1

I have been looking for a C# tree control for displaying a file system that has the following capabilities:

  • Select a starting directory. I don't always want to start at a "default" top directory level.
  • The ability to grab an event when the user double clicks on a file in the tree. I want to handle opening the file within my application.

I have been looking at this C# File Browser. Unfortunately, I have not been able to figure out how to do meet my second need. (If anybody can clear that up for me, I would like that even better.) Thanks for any help.

+3  A: 

Hi I've looked at the C# File Browser and Find a way to handle your 2nd requirement. You could try adding ItemActivate event on the fileView control (under Browser User Control of the FileBrowser project) and get the selected item(s) when handling it. ItemActivate event is triggered on every double click of an item. Here is the sample code:

private void fileView_ItemActivate(object sender, EventArgs e)
    {
        //Loop thru all selected items
        foreach (ListViewItem item in ((BrowserListView)sender).SelectedItems)
        {
            //Do your stuuf here. MessageBox is only used for demo
            MessageBox.Show(item.Text);
        }
    }

Edit by Original Question Writer: To see all of the source, look at the code posted by cipriansteclaru in the comments section of the FileBrowser. You have to actually edit the FileBrowser source to gain this functionality (which is what this answer was demonstrating).

Jojo Sardez
Use Win32 ShellExecute function for actually opening the file. Also look at Shell MegaPack controls: http://www.ssware.com/megapack.htm
logicnp
@logicnp - What is the license of those controls? Are they free to use. I did run across them, but I saw a "Download Trial" link, and I don't like trial software. Plus, I don't want to run into licensing issues as my project is open source.
JasCav
@Jojo Sardez - I am sorry, but I don't actually see how to add the ItemActivate event to the Browser user control. Nothing like that appears to exist within the API. Am I missing something?
JasCav
I was missing something. For those of you who might be looking, I had to actually download the FileBrowser source code and edit that per the instructions of cipriansteclaru. Rebuilt the FileBrowser, and this now works great! Awesome.
JasCav