Reputation: 43
I Have a TextBox(lets call it "ViewTxtBox") and a Button(lets call it "BoldBtn") who does the following:
• User input whatever he wants from the keyboard.
• Once the button clicked the font changes into bold.
BoldBtn Code:
ViewTxtBox.Font = new Font(ViewTxtBox.Font, FontStyle.Bold);
Output If Clicked:
"Hello World I'm all bold and I don't want that"
What I want to do is to change the users' input from the keyboard into bold without change the current content into bold.
Example:
"Hello World"
-----------"Clicks Button"-------------
"Hello World I Pushed The Button And Went Bold"
How can I achieve that?
Upvotes: 1
Views: 281
Reputation: 654
You can achieve that with a RichTextBox. Use the selectionFont property to format the style before the text is added, and your button is clicked, change that selectionFont to Bold.
Upvotes: 2
Reputation: 3043
What's your use case?
The content of a box can have only one font defined by the Font attribute. So to achieve different font, you need different text box, or you need to redesign the full text box data template (or a new user control) to allow several string with different fonts (which seems a lot of trouble to me^^)
Upvotes: 0