Click here to Skip to main content
15,793,452 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Can I use a Label control in a RichTextBox and how do I do it? I want to position the text a certain distance from the border and I can't find any code to do that.
Updated 22-Aug-11 0:31am

While you can add a label control to a RichTextBox, it isn't really a whole lot of use - it sits in front of any text the user is trying to add, and hides the cursor so it isn't obvious to the user what is going on.
Label l = new Label();
l.Text = "MINE!";
Will work!

What are you trying to do that you think this is a good idea?
Share this answer
Terence J 22-Aug-11 5:18am    
I want it in front of the text because I want the text a certain distance from the border. I've search for code to set the text a certain distance from the border, but with no success.
OriginalGriff 22-Aug-11 5:26am    
You can't use a label for that - it does not space out the text, it overlays it. Like putting a playing card on top of the page of a book - the writing is still there, but you can't read the bit obscured by the card.

Have you considered the SelectionIndent property?
Not in Windows forms. You can mark it as readonly though.
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