Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

changing forecolor on a rich text box

Posted on 2014-02-28
2
Medium Priority
?
560 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 86

Accepted Solution

by:
Mike Tomlinson earned 2000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

916 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