CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2008
    Posts
    17

    Changing text color in a text box?

    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......

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Changing text color in a text box?

    This works perfectly for me. Have you changed any other properties in your textbox?

  3. #3
    Join Date
    Nov 2008
    Posts
    17

    Re: Changing text color in a text box?

    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?

  4. #4
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Changing text color in a text box?

    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.

  5. #5
    Join Date
    Nov 2008
    Posts
    17

    Re: Changing text color in a text box?

    Will do- Thanks for your help.........

  6. #6
    Join Date
    Jan 2009
    Posts
    56

    Re: Changing text color in a text box?

    Quote Originally Posted by Shuja Ali View Post
    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...

  7. #7
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Changing text color in a text box?

    Quote Originally Posted by Salbrismind View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured