user3114347
user3114347

Reputation: 369

making some words bold in textbox winform

Maybe some of you can help me with the following problem. I want some words bolded in a textbox(winforms).

I have a string _descripton variable containing some description text. For example: “ this is a description of a \b car \b0………… ”. Im trying to replace the string format with richtextformat like:

string _makebold = _description.Replace("\b", @"{\rtf1\ansi \b").Replace("\b0", " \b0.}");

to get the following result: this is a description of a @"{\rtf1\ansi \b car\b0.}"………. And finally setting the text property of the richtextbox1:

richTextBox1.Text = _makebold;  

I cant get that specific word bolded in a richTextbox and textbox doenst work either.
can anyone help me with a solution?

Thanks!

Upvotes: 0

Views: 2883

Answers (1)

Yogi
Yogi

Reputation: 9759

You can use Rtf property of the rich text box control.

For example, the following text adds the text "This text is in bold." to an existing RichTextBox control.

See this MSDN link.

richTextBox1.Rtf = @"{\rtf1\ansi This is in \b bold\b0.}";

Upvotes: 2

Related Questions