TextColor

S

saurabh

I want to change the color of the text shown in a textbox. Is it easily
achievable in C# ?

TIA,

--Saurabh
 
S

saurabh

Actually what I want to know also is, Why does the ForeColor not change the
color of the text in TextBox whereas a same named property does it in rich
textbox ?

--Saurabh
 
B

Bob Powell [MVP]

You must be doing something odd because the text colour certainly does
change with the forecolor property.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
H

Herfried K. Wagner [MVP]

saurabh said:
Actually what I want to know also is, Why does the ForeColor not change
the color of the text in TextBox whereas a same named property does it in
rich textbox ?

The only reason for this behavior I can think of is that the textbox is
disabled.
 
S

saurabh

Damn me!!
Did not realise that. You are right to some extent. The textbox was
read-only but not disabled (ReadOnly = TRUE, Enabled = TRUE). Now that I
have disabled it but its not read-only then it is showing different color. I
also need to change the BackColor property to control rather than window
(which was default) to get the greyed out look.

Thanks very much for the help,

--Saurabh
 
S

saurabh

Right,

Playing with those properties for a few minutes, I have now realised that
you were absolutely right. If I do not have it enabled, I cannot change the
text color at run time but during design time, if I change the ForeColor, it
does change the text color.

Anyways, It has solved my problem now.

Thanks again for your help,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top