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

RichTextBox colouring

Scheduled Pinned Locked Moved C#
questioncsharp
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.
  • S Offline
    S Offline
    S O S
    wrote on last edited by
    #1

    How can I colour (and set boldness and such things) individual charaters in a RichTextBox? I did this back in VB6 using the SelectionX parameters (they changed the text under selection, not the selection itself as it does in C#), but I can't find anything to do the same thing in C#.

    D 1 Reply Last reply
    0
    • S S O S

      How can I colour (and set boldness and such things) individual charaters in a RichTextBox? I did this back in VB6 using the SelectionX parameters (they changed the text under selection, not the selection itself as it does in C#), but I can't find anything to do the same thing in C#.

      D Offline
      D Offline
      dynamic
      wrote on last edited by
      #2

      here ya go this should get you started off : VB:


      Private void button4_Click(Object sender, System.EventArgs e)
      {
      richTextBox1.SelectionStart=richTextBox1.Text.Length;
      richTextBox1.SelectionColor=Color.Blue;
      richTextBox1.SelectionFont=new Font("Tahoma",10,FontStyle.Bold);
      richTextBox1.SelectedText="testing blue bold\n";
      // now lets change from bold blue to normal red.
      richTextBox1.SelectionStart=richTextBox1.Text.Length;
      richTextBox1.SelectionColor=Color.Red;
      richTextBox1.SelectionFont=new Font("Verdana",10,FontStyle.Regular);
      richTextBox1.SelectedText="now testing in red\n";

          }
      

      hope that helps a little :)


      Private void ExpectingTwins(string twins)
      {
      switch(twins)
      {
      Case ("twins on the way"):
      MessageBox.Show("for mr and mrs dynamic","twins on the way");
      break;
      }
      }


      S 1 Reply Last reply
      0
      • D dynamic

        here ya go this should get you started off : VB:


        Private void button4_Click(Object sender, System.EventArgs e)
        {
        richTextBox1.SelectionStart=richTextBox1.Text.Length;
        richTextBox1.SelectionColor=Color.Blue;
        richTextBox1.SelectionFont=new Font("Tahoma",10,FontStyle.Bold);
        richTextBox1.SelectedText="testing blue bold\n";
        // now lets change from bold blue to normal red.
        richTextBox1.SelectionStart=richTextBox1.Text.Length;
        richTextBox1.SelectionColor=Color.Red;
        richTextBox1.SelectionFont=new Font("Verdana",10,FontStyle.Regular);
        richTextBox1.SelectedText="now testing in red\n";

            }
        

        hope that helps a little :)


        Private void ExpectingTwins(string twins)
        {
        switch(twins)
        {
        Case ("twins on the way"):
        MessageBox.Show("for mr and mrs dynamic","twins on the way");
        break;
        }
        }


        S Offline
        S Offline
        S O S
        wrote on last edited by
        #3

        Thanks! Exactly what I needed :)

        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