获取 System.Windows.Forms.RichTextBox 的标准上下文菜单

发布于 2024-08-21 03:23:52 字数 141 浏览 3 评论 0原文

如何在 RichTextBox 中获取标准上下文菜单,如 TextBox 中的菜单(复制、粘贴、IME 等)?如果没有现成可用的解决方案,我会选择 P/Invoke 解决方案。或者我真的必须遵循那些奇怪的建议来创建自定义菜单才能获得标准菜单(叹息)?

How can I get the standard context menu in a RichTextBox, like the one in TextBox (Copy, Paste, IME etc.)? I'd go with a P/Invoke solution if nothing is available out of the box. Or do I really have to follow those strange advices to create a custom menu to get a standard menu (sigh)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一江春梦 2024-08-28 03:23:52

RichTextBox 的 ContextMenuStrip 属性可以分配给用户设计的上下文菜单、复制/剪切/粘贴,只需将 RichTextBox 的方法应用于每个菜单项(例如 CanUndo、CanCopy、CanPaste)即可确定菜单项的 Enabled 属性。使用方法“复制剪切粘贴”将是菜单项点击事件的执行方法。

希望这有帮助,
此致,
汤姆.

The ContextMenuStrip property of the richtextbox can be assigned to a user designed context menu, Copy/Cut/Paste and just apply the RichTextBox's methods to each of the menu items such as CanUndo, CanCopy, CanPaste to determine the menu item's Enabled property. Using the methods 'Copy,CutandPaste` will be the executed method for the menu item's click event.

Hope this helps,
Best regards,
Tom.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文