To disable the context menu in OpenFileDialog or CommonOpenFileDialog in C#, you can use the following approach:
using System;
using System.Windows.Forms;
public class CustomOpenFileDialog : OpenFileDialog
{
protected override void WndProc(ref Message m)
{
const int WM_CONTEXTMENU = 0x007B;
if (m.Msg == WM_CONTEXTMENU)
{
// Disable the context menu by not calling the base class implementation
return;
}
base.WndProc(ref m);
}
}
In your code, replace the usage of OpenFileDialog with CustomOpenFileDialog to disable the context menu.
using Microsoft.WindowsAPICodePack.Dialogs;
CommonOpenFileDialog dialog = new CommonOpenFileDialog();
dialog.AllowPropertyEditing = false;
By setting AllowPropertyEditing to false, the delete menu option will be disabled in the CommonOpenFileDialog.
Please note that the above solutions are specific to disabling the context menu and delete menu in OpenFileDialog and CommonOpenFileDialog respectively. They do not cover other aspects of the mentioned technologies or concepts.
没有搜到相关的沙龙