开发者

Editing WinForms RichTextBoxControl C#

How can you add text to a RichTextBox control开发者_JS百科 and change the font style as you add text?


Found an excellent library on Code Project which provides an RTFStringBuilder which allows the settings of formatting as the stringbuilder is built up. Setting the RichTextBox's RTF property to the RTFStringBuilder.ToString() does just the job I need. Thanks seeblunt!


Assuming you mean add text programmatically....

RichTextBox myTB = new RichTextBox();

myTB.Text += "Some text";

-- or --

myTB.AppendText("Some other Text");

As for changing the font, you could add an event handler to your richtextbox to get notified when the text changes.

myTB.TextChanged += new EventHandler(myTB_TextChanged);

and set the font of myTB in that event handler.

Just a thought.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜