winforms - How can I show a FolderBrowserDialog more than once? -


In the form_load event of my Windows form, I want to show a FolderBrowserDialog to let the user choose a directory, and if they The directory 'selected' is not valid (i.e. there is a lack of certain files which needs an application), I want to show it again though, when I make a new FolderBrowserDialog, when I call ShowDialog Can not see.

  while (ValidDirectorySelected () == false & amp; TryAgain == true) {(FolderBrowserDialog dialog = new folder browser dialog ()) {dialog.ShowNewFolderButton = false; If (dialog.ShowDialog () == System.Windows.Forms.DialogResult.Cancel) {tryAgain = false; }}}  

When I move in, dialogue. Shodiology () rises to the second time, and then nothing happens. The dialog does not appear, and the debugger does not move forward. It just stops, it works completely for the first time, but not the second, I have tried to paste it just before using that entire block, and so on.

Solution:

What do I need to do to display more than once?

Solution:

Passing Shadiyoga to 'this' fixed my problem. I used to quit without refusing any dialogue again, while using the outside of the loop. Minimize visual studios, you'll get the dialog back.

This is a focus issue, because you display dialog in the load event. When the dialog stops, there is no window left in your app that can get the focus Your running event is not finished running, so the main window of the app is not visible yet. Windows will have to get a window to focus and one will be selected from another program. Like Visual Studio

When you display the dialog again, the focus can not be stolen because the visual studio has achieved it, then the dialog behind the main window of the Visual Studio is out of view Comes.

You have to fix this by seeing your main window and the call dialog. Shodelogg (it) be absolutely sure For example, you can use the events shown.


Comments