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

    Wink Changing Text colour

    Hi Guys

    I have a textbox on my form that i want to change the colour of the text.

    I want to change the colour so it has 3 different colours set:

    - Any text that is enclosed in quote marks (e.g "this text is black") is set to black.
    - The Certain Characters left bracket(<) right bracket(>) forward slash(/) quote marks(") and equals sign(=) are set to blue
    - All other text is set to Red

    Is there a way of doing this?

    I have used the below code and it changes the whole text to the colour Red:

    TextBox1.ForeColor = Color.Red

    Is there a way now of specifying which text is set to which colour as per the above statements?

    Kind Regards,
    Chloe ~X~

  2. #2
    Join Date
    Dec 2003
    Location
    Northern Ireland
    Posts
    1,362

    Re: Changing Text colour

    You need a rich text box. You will have to run your text through a parsing function to format it into rich text format (there are docs online describing the format). You probably want to save the original text and parse into the rich textbox for display purposes.
    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook


    0100 1101 0110 1001 0110 0011 0110 1000 0110 0001 0110 0101 0110 1100 0010 0000 0100 0101 0110 1100 0110 1100 0110 0101 0111 0010

  3. #3
    Join Date
    Dec 2003
    Location
    Northern Ireland
    Posts
    1,362

    Re: Changing Text colour

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook


    0100 1101 0110 1001 0110 0011 0110 1000 0110 0001 0110 0101 0110 1100 0010 0000 0100 0101 0110 1100 0110 1100 0110 0101 0111 0010

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