Changing Color in a text box

  • Thread starter Thread starter Brad Markisohn
  • Start date Start date
B

Brad Markisohn

I would like to display a text box where some of the content is displayed in
a different color. Can I do this with a text box control? If not could
somebody please suggest a way in which I might do this or send me a link to
an example?

TIA

Brad
 
I can't believe that I'll need to write my own textbox to have text with
multiple colors. An example of what I'm looking to do is: I'm monitoring
serial communication. I'm displaying both ends of the communication, but I
want the input data to be a different color than the output data. Is this
something that I could do with the Rich Text Box control? Any other
suggestion?

TIA

Brad
 
Hi Brad,

Based on my understanding, you want to apply different color for the text
in textbox control.

Actually, you should use RichTextBox to get this done. TextBox control does
not support this function, for more information, please refer to:
http://www.codeproject.com/vb/net/richtextboxhs.asp?target=richtextbox
http://www.codeproject.com/cs/miscctrl/csexrichtextbox.asp?target=richtextbo
x

Also, there is an already developed assembly dll at article below:
http://www.codeproject.com/vb/net/tarrorichtextbox.asp?target=richtextbox#xx
484272xx

Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
I can't believe that I'll need to write my own textbox to have text with
multiple colors. An example of what I'm looking to do is: I'm monitoring
serial communication. I'm displaying both ends of the communication, but I
want the input data to be a different color than the output data. Is this
something that I could do with the Rich Text Box control? Any other
suggestion?

TIA

Brad

You should be able to do this using a Rich TextBox.

Good luck!
Jan Roelof
 
Brad said:
I would like to display a text box where some of the content is displayed in
a different color. Can I do this with a text box control? If not could
somebody please suggest a way in which I might do this or send me a link to
an example?

Using a RichTextBox instance:

richTextBox.SelectionStart = richTextBox.TextLength;
richTextBox.SelectionColor = Color.Red;
richTextBox.SelectedText = "Red" + Environment.NewLine;
richTextBox.SelectionColor = Color.Blue;
richTextBox.SelectedText = "Blue" + Environment.NewLine;
 
Thanks for the assistance.

Brad

C# Learner said:
Using a RichTextBox instance:

richTextBox.SelectionStart = richTextBox.TextLength;
richTextBox.SelectionColor = Color.Red;
richTextBox.SelectedText = "Red" + Environment.NewLine;
richTextBox.SelectionColor = Color.Blue;
richTextBox.SelectedText = "Blue" + Environment.NewLine;
 
Use the Style Class and associate the style sheet to the textbox object.

txt1.AssignCSS("") // some such syntax. please check the actual syntax
as right now I do not have access to the .Net Framework.


with regards,


J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com
 
Back
Top