Results 1 to 4 of 4

Thread: Change Text Color in Code

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Posts
    79

    Change Text Color in Code

    Hi Guys,

    So I have a RichTextBox for a Chat, And I was just wonder how i can change the color of the text in the code. I know you can change the foreground color in the application its self, but I need to change the color IN THE CODE. Please let me know how. Thanks guys :-)

  2. #2
    Addicted Member Mal1t1a's Avatar
    Join Date
    Mar 2008
    Posts
    157

    Re: Change Text Color in Code

    If I understand you correctly, this is what you are looking for:

    Code:
    RTB.ForeColor = Color.Red

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Posts
    79

    Re: Change Text Color in Code

    Now How can i apply that to the text.

    For Example

    RichTextBox1.AppendText("<System>" & TimeOfDay & vbCrLf)

    How could i change the color of <System> to Red

  4. #4
    Addicted Member Mal1t1a's Avatar
    Join Date
    Mar 2008
    Posts
    157

    Re: Change Text Color in Code

    Here's a quick way of doing it, but mind you, It's thrown together, and not particularly effective.

    Code:
    RichTextBox1.AppendText("<System>" & TimeOfDay & vbCrLf)
            RichTextBox1.Select(RichTextBox1.TextLength - ("<System>" & TimeOfDay & vbCrLf).Length + 1, ("<System>" & TimeOfDay & vbCrLf).Length - 1)
            RichTextBox1.SelectionColor = Color.Red
            RichTextBox1.DeselectAll()

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