C# 从文本框中禁用默认窗口上下文条
我已禁用整个表单中的默认上下文条,并用我自己的上下文条替换。 在我的上下文菜单条中,我有一个工具条文本框,但是在其中右键单击时,它会显示默认的 Windows 上下文菜单。 预先感谢您的所有回复, 问候, 戴夫
I have disabled the default context strip throughout my form, and replaced with my own.
Within my contextmenustrip i have a toolstriptextbox, however when right-clicking within this it brings up the default windows context menu..
Thanks in advance for any and all replies,
Regards,
Dave
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
删除默认右键单击菜单的最简单方法是定义您自己的(空)菜单:
这将在一行中删除默认的 Windows 右键单击选项。了解键盘快捷键(Ctrl-C、Ctrl-X、Ctrl -V、Ctrl-A、 Ctrl-Z)仍然有效;您没有禁用基本功能,只是禁用鼠标访问它。
对于另一个 TextBox 的 ContextMenu 中的 TextBox,这有点棘手,但基本上您可以使用该项目的 TextBox 属性直接访问 ToolStripItem 中包含的 TextBox。此属性是一个普通的
System.Windows.Forms.TextBox
,与您应用中的任何其他属性一样:Easiest way to remove the default right-click menu is to define your own (empty) menu:
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: