Disable Right click in FolderBrowserDialog - wpf?

 System.Windows.Forms.FolderBrowserDialog dlg = new FolderBrowserDialog();
 HwndSource source = PresentationSource.FromVisual(this) as HwndSource;
 System.Windows.Forms.IWin32Window win = new OldWindow(source.Handle);
 System.Windows.Forms.DialogResult result = dlg.ShowDialog(win);

      

I used this to get the folder dialog, but now I need to disable the right click on that folder dialog so that I can prevent folders from being deleted there. enter code here

Create a custom folder. The dialog box is the last option I want to use.

So, can anyone suggest any possible solution for this without a dedicated Dialog folder.

+3


source to share


2 answers


You can not. The class cannot be inherited, so you cannot override any settings. There are no events.

So, you have several options:



  • Roll your own
  • Use the file system to lock the user state.
  • Buy a third party control that has this feature.

We chose option 2 because the end users didn't need to use the "regular" Windows applications / files on our RDP server, they just needed to run our application. An organizational unit (OU) is added to the applied permissions so that they only have access to the folders they wanted to have access to. They can't see any of the normal items that you see when the dialog is displayed, but they can create folders, save items, load items from folders that we allow them to use.

+1


source


Ravindra,

Since Delete in ContextMenu is a Windows function, you will have to change the registry settings.

Basically, you need to modify / delete the "Delete" registry entry, and after executing your code, you should restore it.



You can find the entry in the registry: HKEY_CLASSES_ROOT. (You will really take some time to understand this entry).

Example:

  System.Windows.Forms.FolderBrowserDialog fd = new System.Windows.Forms.FolderBrowserDialog();

  //Get key for New menu option in Context menu.
  RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"Directory\Background\shellex\ContextMenuHandlers\New",true);

  //Set it to blank.
  key.SetValue("", "");
  fd.ShowDialog();

  //Restore the value.
  key.SetValue("", "{D969A300-E7FF-11d0-A93B-00A0C90F2719}");`

      

0


source







All Articles