-
Jul 11th, 2005, 02:12 AM
#1
Thread Starter
Addicted Member
RichTextBox BackColor
Hi all
How do we change the backcolor of a portion of text in a RichTextbox. I know that there is a method to change the font color of a portion of text in the richtextbox but I want to know how to change the back color.
Thanx in advance
Cute Member
-
Jul 11th, 2005, 07:25 AM
#2
Re: RichTextBox BackColor
Try
Code:
private void Detail_Format(object sender, System.EventArgs eArgs)
{
RichTextBox1.BackColor = System.Drawing.Color.DarkGoldenrod;
}
-
Dec 12th, 2005, 04:46 AM
#3
Thread Starter
Addicted Member
Re: RichTextBox BackColor
Originally Posted by Hack
Try
Code:
private void Detail_Format(object sender, System.EventArgs eArgs)
{
RichTextBox1.BackColor = System.Drawing.Color.DarkGoldenrod;
}
This works for the entire richtextbox. I dont want to change the backcolor of the entire RichTextBox only of the selected text in the rich text box. The RichTextBox might contain more than 2 words in it. If a portion of the 1st word is selected, then the back color of the selected portion should change (of course this will be in button click event or some thing compatible)
Cute Member
-
Dec 12th, 2005, 07:09 PM
#4
Re: RichTextBox BackColor
I've not used the RTB myself but it looks like it doesn't support adding a background colour to a portion of text directly. It seems that you would have to manipulate the Rtf property yourself, which is obviously best avoided if possible. Check out this extended RichTextBox that adds just that functionality. I think the code is in VB.NET but it shouldn't be too hard to convert. Try the converter in my signature if you need help, but keep in mind that it's not 100% reliable (although it does a good job) and it won't always produce the most efficient code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|