Click here to Skip to main content
15,888,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Since my previous post was closed due to a lac of information, I'd like to start a new one....

I'm developing an addin for OneNote 2010 which opens a Windows Form. I used this site as a guide. Everything works well: Forms are shown, statements are executed and pages are filled by information I want...

I'm having trouble by showing the folder browser. I want to put the selected folder in a textbox or label for further use, but when I press the button, the form hangs. The only way to stop this is using the Windows Taskmanager.

For showing the Folder Browser dialog, I'used the component placed on a form and by code, none of them works.

Here the simple code for showing the dialog:

C#
FolderBrowserDialog fd = new FolderBrowserDialog();
fd.Description = "Please choose";
if (fd.ShowDialog() == DialogResult.Cancel)
{
    this.Hide();
}

txtFolder.Text = fd.SelectedPath;


Let me know if there if more information needed.
Kind regards,
Piet
Posted

1 solution

I think the explanation may be simple: this.Hide(); hides your Form.

Try:
FolderBrowserDialog fd = new FolderBrowserDialog();

fd.Description = "Please choose";

if (fd.ShowDialog() == DialogResult.OK)
{
    txtFolder.Text = fd.SelectedPath;

    // continue with code based on having
    // a valid folder reference
}
So, a lot depends here on what the "this" in this.Hide(); refers to.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900