formatting in a richtextbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,

i have a richtextbox in my app. when a button is disabled, the richtextbox
control should say "The button is now disabled". only the word disabled
should be emboldened. how do i make only the word bold?

my code so far is

if (Button1.Enabled = false)
{
richTextBox1.Text = "The button is now disabled";
}
 
You can either use a combination of SelectedText and SelectionFont e.g.
richTextBox1.SelectedText="The button is now ";
richTextBox1.SelectionFont=New
Font(currentFont.FontFamily,currentFont.Size,FontStyle.Bold);
richTextBox1.SelectedText="disabled";

or else pipe in the RTF characters directly e.g.
richTextBox1.Rtf = @"{\rtf1\ansi The button is now \b disabled\b0.}";

Cathal
 
Back
Top