Solved

changing forecolor on a rich text box

Posted on 2014-02-28
2
488 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 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

15 Experts available now in Live!

Get 1:1 Help Now