Edouard Durand

Edouard Durand

  • NA
  • 46
  • 20.9k

How to make CommonOpenFileDialog a modal window?

Jul 14 2020 5:14 PM

Hello,

I use CommonOpenFileDialog to make possible the choice of a folder but the window is not modal, it is possible to swith another window and run actions and I do not want that.

I would like that CommonOpenFileDialog is a modal window, in other word, not possible to swith another window.

Here is my code:
  1. public static void ChooseFolder(TextBox textbox)          
  2. {              
  3. CommonOpenFileDialog openFolder = new CommonOpenFileDialog();  
  4. openFolder.InitialDirectory = textbox.Text;  
  5. openFolder.AllowNonFileSystemItems = true;      
  6. openFolder.Multiselect = false;       
  7. openFolder.IsFolderPicker = true;    
  8. openFolder.Title = "Select folder";  
  9.   if (openFolder.ShowDialog() == CommonFileDialogResult.Ok)   
  10.   {     
  11.    textbox.Text = openFolder.FileName;   
  12.   }                     
  13. }        
  14. }  
 

How to solve this issue?

Thanks.


Answers (1)