Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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!
Posted
Comments
Bala Selvanayagam 23-Oct-11 15:58pm    
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
[no name] 24-Oct-11 2:50am    
Your reference link is very helpful to me, thank you very much! Why didn't you post it as your solution so that now I could accept your solution?
Bala Selvanayagam 24-Oct-11 3:32am    
Thanks King,

Posted as my solution

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:
C#
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;
}
 
Share this answer
 
v2
Comments
[no name] 24-Oct-11 2:44am    
Thank you very much! I have read an article on stackoverflow and know that we can use the API function HideCaret, your solution is much worthy to try!
Thank you!
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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900