简体   繁体   中英

How can i make a button for Bold a selected text in Textbox/Richtextbox in WPF?

I need to make a Button for bolding selected text of a string in TextBox / RichTextBox , but I don't know how to do it with code behind.

TextBox1.SelectedText = new FontStyle("Bold")

It is not working.

试试这个富文本框的代码:

RichTextBox1.Selection.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM