How to make text in a WinForms TextBox unselectable without disabling it?(如何在不禁用的情况下使 WinForms TextBox 中的文本不可选择?)
问题描述
是否可以在不禁用 TextBox 的情况下使 TextBox 中的文本无法选择?这是一个 RichTextBox,我需要它的格式和选择功能.我无法禁用它,因为我想处理 MouseMove 和 MouseDown 事件.
Is it possible to make the text in a TextBox unselectable without disabling the TextBox? It's a RichTextBox and I need it's formatting and selection features. I can't disable it because I want to handle MouseMove and MouseDown events.
到目前为止,我一直在考虑禁用文本框并在其顶部放置一个面板,将其事件委托给文本框处理程序,但我无法使面板透明,因此它隐藏了文本框.
So far I've thought about disabling the Text box and putting a panel on top of it which will delegate it's events to the textbox handlers, but I can't make the panel transparent so it hides the textbox.
谢谢.
推荐答案
如何处理 .Enter 或 .GotFocus 事件以清除所做的任何选择?
您可以在 自动选择所有文本中看到与您想要的相反的内容WinForms TextBox 中的焦点.
What about dealing with the .Enter or .GotFocus events to clear any selection made?
You can see the opposite of what you wanted in Automatically select all text on focus in WinForms TextBox.
这篇关于如何在不禁用的情况下使 WinForms TextBox 中的文本不可选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在不禁用的情况下使 WinForms TextBox 中的文本不可选择?
基础教程推荐
- 全局 ASAX - 获取服务器名称 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
