RichTextBox colouring
-
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#.
-
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#.
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;
}
}
-
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;
}
}