开发者

Tree View / File View Control for C#

开发者 https://www.devze.com 2022-12-22 09:10 出处:网络
I have been loo开发者_C百科king for a C# tree control for displaying a file system that has the following capabilities:

I have been loo开发者_C百科king 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.


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消