如何使一个WinForms TextBox中不可选择的文本没有禁用呢? [英] How to make text in a WinForms TextBox unselectable without disabling it?

查看:175
本文介绍了如何使一个WinForms 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.

感谢。

推荐答案

怎么样对付。进入或.GotFocus事件以清除任何选择做?

你可以看到您在自动选择的WinForms焦点的所有文本对面是什么文本框。

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天全站免登陆