473,385 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

C# - Form: different words in richtextbox to be different colors

3
I have created a chat program, and i want the usernames to be a different color then the other words in the richtextbox that i have.
i have googled this and i did not find any suitable answer.
Please help.
-thanks
Aug 4 '08 #1
1 3228
Plater
7,872 Expert 4TB
There are a couple of ways to do this. One is to have a bit of know-how with RTF(can be hard).
The other is (maybe only in .NET2.0 and later) to use the proeprties outlines for the RichTextBox.
.SelectionColor and .SelectionBackColor (among others)
You would set these to the colors you would want, append the username to the text, then change the colors back to the regular values (black text on white background for example)

As an example:
Expand|Select|Wrap|Line Numbers
  1. void AddMessage(string Username, string MsgText)
  2. {
  3.    myRichTextBox.SelectionColor = Color.Red;
  4.    myRichTextBox.AppendText(Username);
  5.    myRichTextBox.SelectionColor = Color.Black;
  6.    myRichTextBox.AppendText(MsgText);
  7. }
  8.  
Aug 4 '08 #2

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

Similar topics

0
by: Atara | last post by:
Is there a way I can use different references for different configurations of my project? I have different project (and solution) configurations. Do I have to 'Add reference' of all the dll's I...
3
by: Nerrad | last post by:
hi guys, i have a project on my hand and what i'm told to do is to create a log-in feature using tables and forms. Da question is that is there any way to allow different users different access...
9
by: antonyliu2002 | last post by:
I am not sure how to google this concept. Basically, what I wanna do is to direct different users to different pages. I do not have a whole lot users. For example, if user name 'tomcat'...
5
by: shivak | last post by:
Hi I have designed a MS Access database for progress report(grade) for students in a school. We have different classes with different subjects. Now I am using different forms for each section...
2
by: =?Utf-8?B?U3Bpcml0RmxhZw==?= | last post by:
I want to configure different sessionState on different subdirectory,so I wote this code in wen.config file: <location path="SubInProc"> <system.web> <sessionState mode="InProc"...
2
by: Peter Oliphant | last post by:
I'm developing a program at home on a Windows Vista computer. In it I create a form with a few buttons on it that fill up the form's visible area. So, I took the application to work, where I use...
3
by: sudhashekhar30 | last post by:
hi all i am using formview control(asp.net 2.0) 1rst time. don't know much about it. i want to display record in it from different tables at different time. like 1rst time form view is showing...
1
vdraceil
by: vdraceil | last post by:
Is it possible to set different forecolors to different words in a text(within a textbox)?If not possible in a textbox then is it possible in a rich text box or any other activex component?
3
by: huda81 | last post by:
Dear all, I need help in creating this system really got tired by searching. I am new baby born programmer (^_^). The requirments are: Develop a Java applet that draws different shapes of...
5
by: Christopher Brewster | last post by:
I am running the same script on the same data on two different machines (the folder is synchronised with Dropbox). I get two different results. All the script does is count words in different...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.