Click to See Complete Forum and Search --> : Changing text color in a text box?
TheBigHam
March 11th, 2009, 06:13 AM
Hi All
I am using Visual C# 2008 to design a small application.
I cannot seem to change the color of text within a textBox, the code I am using but will not work is:
textBoxName.ForeColor = Color.White;
Thanks in advance for your help.......
Cheers,
Paul......
Shuja Ali
March 11th, 2009, 06:28 AM
This works perfectly for me. Have you changed any other properties in your textbox?
TheBigHam
March 11th, 2009, 06:39 AM
Yea- I have textBoxName.Enabled = False;
When I change this to True I can change the text color but I don't want the user to be able to edit the text within this text box thats why I originally set it to false.
Do you have any suggestions to overcome this?
Shuja Ali
March 11th, 2009, 06:45 AM
Yes I have a suggestion. If your text box is going to be disabled then I would suggest using a label instead. This is the correct way of displaying read-only data.
TheBigHam
March 11th, 2009, 06:51 AM
Will do- Thanks for your help.........
Salbrismind
March 11th, 2009, 06:57 AM
Yes I have a suggestion. If your text box is going to be disabled then I would suggest using a label instead. This is the correct way of displaying read-only data.
What if you have a lot of text to show? Labels don't wrap the string to the next line...
Shuja Ali
March 11th, 2009, 07:21 AM
What if you have a lot of text to show? Labels don't wrap the string to the next line...
Set AutoSize property to false and see if the Label wraps the text to next line or not.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.