Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Different font colors in RichTextBox

Different font colors in RichTextBox

Scheduled Pinned Locked Moved C#
sysadminquestionlounge
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    johland
    wrote on last edited by
    #1

    hi, in a client/server chat application the client can choose his fave font color and the server shld spread each client messages in its own unique font color. is there away to do that with the clients form displays messages in a richTextBox? (the only way i managed to do that is with listView) many thanks

    M 1 Reply Last reply
    0
    • J johland

      hi, in a client/server chat application the client can choose his fave font color and the server shld spread each client messages in its own unique font color. is there away to do that with the clients form displays messages in a richTextBox? (the only way i managed to do that is with listView) many thanks

      M Offline
      M Offline
      mav northwind
      wrote on last edited by
      #2

      Hi! You'd have to use the SelectionColor property for that. For example, something like this should work:

      richTextBox1.Select(startOfMessage, 0);
      richTextBox1.SelectionColor = Color.Red;
      richTextBox1.SelectedText = "Message from User 1" + Environment.Newline;
      richTextBox1.SelectionColor = Color.Blue;
      richTextBox1.SelectedText = "Second message from User 2" + Environment.Newline;

      Regards, mav -- Black holes are the places where God divided by 0...

      J 1 Reply Last reply
      0
      • M mav northwind

        Hi! You'd have to use the SelectionColor property for that. For example, something like this should work:

        richTextBox1.Select(startOfMessage, 0);
        richTextBox1.SelectionColor = Color.Red;
        richTextBox1.SelectedText = "Message from User 1" + Environment.Newline;
        richTextBox1.SelectionColor = Color.Blue;
        richTextBox1.SelectedText = "Second message from User 2" + Environment.Newline;

        Regards, mav -- Black holes are the places where God divided by 0...

        J Offline
        J Offline
        johland
        wrote on last edited by
        #3

        I will try that, Thanks

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups