By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,441 Members | 998 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,441 IT Pros & Developers. It's quick & easy.

richtextbox -> formatting text problem

P: 1
Hello,

I want to use a richtextbox for logging status messages. I have three kind of message types and want to use different formatting for them.

My problem is, I change the color, add the text and the added text is shown in another color. I scroll to the end and want to add the next status line using appendtext. But now the previous line lost its formatting......
I want to keep the formatting… Do you have a solution? BTW I am using managed C++….


Here the code:
richtextbox->SelectionStart = richtextbox->Text->Length - 1;
richtextbox->SelectionColor = System::Drawing::Color::Blue;
richtextbox->SelectedText = text;
richtextbox->ScrollToCaret();

Cheers,
Claus
Apr 27 '07 #1
Share this Question
Share on Google+
2 Replies


P: 50
I tried your code because of a scrolling problem I'm having. It seems that if you have the -1 from
richTextBox1->SelectionStart = richTextBox1->Text->Length -1;
it changes the color back to default black for me. If I take out the -1 than my color stays red which it's suppose to be. Although when I tried the font and the font size that didn't seem to matter if the -1 was there or not.

BTW do u know how to scroll to the next line as soon as something is entered without typing it in the richtextbox yourself. My functions find out info and display it but it doesn't scroll down along with every new entry. It only scrolls down if I'm typing into the richtextbox directly.

Thanks
Jul 25 '07 #2

Plater
Expert 5K+
P: 7,872
Don't set selection start.
All you need to do is set the colors/format/whatever then add the text.
Jul 25 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.