Solved

changing forecolor on a rich text box

Posted on 2014-02-28
2
477 Views
Last Modified: 2014-03-03
hi - I want to update a rich text box with data that has some characters color changed from black to red. is this possible using a RTB? the application involves showing the user by a change in color that certain text values have changed from one pass of the data to the next pass.
if it's not possible with a RTB, is there another approach I can take?
what I'm doing now is below (it doesn't work):

for (int k = 1; k < tempReply[0] + 1; k++)
                        {
                            if (totalBytes++ < size)
                            {
                                if (oldVars[k] != tempReply[k + 1] && !firstTime)                               
                                    displayVars_TB.ForeColor =  Color.Red;                                                                
                                else
                                    displayVars_TB.ForeColor = Color.Black;

                                Application.DoEvents();
                                displayVars_TB.AppendText( tempReply[k].ToString("X2") + " ");
                                Application.DoEvents();
                            }
                            else
                                break;
                           
                        }

Open in new window


thanks,
0
Comment
Question by:jdcoburn
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 39895825
Sure it's possible.

Just move your SelectionStart() to the end of the RichTextBox, set the SelectionColor(), then call AppendText():
            for (int k = 1; k < tempReply[0] + 1; k++)
            {
                if (totalBytes++ < size)
                {
                    displayVars_TB.SelectionStart = displayVars_TB.TextLength;
                    if (oldVars[k] != tempReply[k + 1] && !firstTime)
                        displayVars_TB.SelectionColor = Color.Red;
                    else
                        displayVars_TB.SelectionColor = Color.Black;
                    displayVars_TB.AppendText(tempReply[k].ToString("X2") + " ");
                    Application.DoEvents();
                }
                else
                    break;
            }

Open in new window

0
 

Author Closing Comment

by:jdcoburn
ID: 39902247
thank you, nicely done.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now