如何在RichTextBox中隐藏插入符号? [英] How to hide the caret in RichTextBox?

查看:98
本文介绍了如何在RichTextBox中隐藏插入符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果可以的话,您能告诉我如何实现吗?
万一我们需要richtextbox只显示一些富文本,并且我认为插入符号应该是不可见的.

Could you please tell me the how to achieve that if we can?
In case we need the richtextbox to display some richtext only and I think the caret should be invisible.
Thank you very much!

推荐答案

这个建议的解决方案值得偷偷摸摸的万圣节把戏,但是...有效...有点...:)

1.在您的窗体上放置一个真正的小标签,将其文本设置为空字符串.设置其背景颜色以匹配表单"颜色,或者甚至可以将其背景颜色设置为透明".或者把它放在后面:)

2.为RichtTextBox1定义"Enter"和"Leave"事件:
Well this proposed solution is worthy of a sneaky Halloween trick, but ... it works ... kinda ... :)

1. put a real small label on your Form, set its Text to an empty string. set its background color to match the Form color, or you can even set its background color to Transparent. Or put it behind something :)

2. Define ''Enter and ''Leave events for your RichtTextBox1:
private void richTextBox1_Enter(object sender, EventArgs e)
{
    // want to clear any current selection: use this:
    //richTextBox1.SelectionLength = 0;
    //richTextBox1.SelectionStart = 0;

    // what's unfortunate here is that
    // there is no simple way to turn-off
    // the cursor completely ... not without
    // ... as I understand it ... using pInvoke
    // whether any of the alternate cursors you
    // can change it to would be satisfactory
    // to you ... I don't have a clue !
    // Want a circle with a diagonal stripe:
    // richTextBox1.Cursor = Cursors.No;

    label1.Focus();
}

private void richTextBox1_Leave(object sender, EventArgs e)
{
    Cursor = Cursors.Default;
}


您尝试谷歌搜索

我只是尝试过并认为这对您有帮助

http://stackoverflow.com/questions/582312/how-to- hide-the-caret-in-a-richtextbox [ ^ ]
Did you try googling

I just tried and thought this is helpfull

http://stackoverflow.com/questions/582312/how-to-hide-the-caret-in-a-richtextbox[^]


这篇关于如何在RichTextBox中隐藏插入符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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