如何在不禁用的情况下使 WinForms TextBox 中的文本不可选择? [英] How to make text in a WinForms TextBox unselectable without disabling it?

查看:13
本文介绍了如何在不禁用的情况下使 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 中的文本不可选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆