1

フォーム全体でデフォルトのコンテキスト ストリップを無効にし、独自のものに置き換えました。contextmenustrip内に toolstriptextbox がありますが、これを右クリックすると、デフォルトの Windows コンテキスト メニューが表示されます。

4

1 に答える 1

6

Easiest way to remove the default right-click menu is to define your own (empty) menu:

myTextBox.ContextMenuStrip = new ContextMenuStrip();

This will, in one line, remove the default Windows right-click options. Understand that the keyboard shortcuts (Ctrl-C, Ctrl-X, Ctrl-V, Ctrl-A, Ctrl-Z) will all still work; you're not disabling the basic functionality, just the mouse-able access to it.

For a TextBox within a ContextMenu of another TextBox, it's a little trickier, but basically you can directly access the TextBox that is contained within the ToolStripItem, using the item's TextBox property. This property is a vanilla System.Windows.Forms.TextBox, like any other you'd have in your app:

myToolStripTextBox.TextBox.ContextMenuStrip = new ContextMenuStrip();
于 2011-12-16T17:50:59.710 に答える