如何在未聚焦的 WinForms TextBox/RichTextBox 中显示光标?
我需要在 WinForms 应用程序的 RichTextBox 控件中显示光标,即使它没有焦点。我该怎么做?我只找到了 WPF 的方法( 如何保持 WPF TextBox 选择什么时候注意力不集中?)
I need to show cursor in RichTextBox control in WinForms application even when it's not in focus. How can I do this? I found only the way for WPF ( How to keep WPF TextBox selection when not focused?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 WinAPI ..
并随时调用 ShowCaret
You can use WinAPI ..
and call ShowCaret whenever you want
您无法同时将焦点设置到两个或多个 UI,但可以通过设置
HideSelection=false
保留选择。You can't set focus to the two or more UI at same time however you can preserve the selection by setting
HideSelection=false
.我不知道您想要实现什么目标以及它真正有用的程度有多少。但如果只是为了视觉目的,请写一些类似“|”的东西在其中。这是一种糟糕的、奇怪的、尴尬的方式,或者无论你怎么称呼它,出于视觉目的它可能会起作用。
我不确定我给出的是否是您所要求的,但为了得到准确的答案,您必须暴露您对此要求的需求。
希望有帮助。
I don't know what you are trying to achieve and how much is it really useful. But if it is just for visual purpose, write some thing like '|' in it. Its a bad, weird, awkward way or what ever you call it, for visual purpose it may work.
I am not sure if I am giving is what you are asking, but to get accurate answer, you have to expose your need of this requirement.
Hope it helps.