Groups | Blog | Home
all groups > dotnet windows forms > january 2005 >

dotnet windows forms : TextColor


saurabh
1/7/2005 4:06:11 PM
I want to change the color of the text shown in a textbox. Is it easily
achievable in C# ?

TIA,

--Saurabh

saurabh
1/7/2005 4:17:10 PM
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

[quoted text, click to view]

Bob Powell [MVP]
1/7/2005 6:35:26 PM
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.





[quoted text, click to view]

Herfried K. Wagner [MVP]
1/8/2005 1:37:25 AM
"saurabh" <saurabh@nagpurcity.net> schrieb:
[quoted text, click to view]

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

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
saurabh
1/10/2005 9:38:01 AM
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

[quoted text, click to view]

saurabh
1/10/2005 10:24:03 AM
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,


[quoted text, click to view]

AddThis Social Bookmark Button