Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
how can i change a format of a sentence in a TextBox?

for example in this text:

"This is a bold text.
This is a italic text.
This is a highlighted text!!!!
"

or how can i have a text container that i can change the attributes of a specific text in it? something like searching in word document.
Posted

Hi !

For C#/Windows Application : you cannot format text in a textbox (i.e. make it bold, italic, underlined, etc.). Better use RichTextBox for that purpose

For WPF : I'm not really sure but I would do that in a stylesheet (css)
 
Share this answer
 
Comments
Simon Bang Terkildsen 22-Aug-11 10:57am    
Stylesheet (css) has nothing to do with WPF.
You would use a RichTextBox in WPF as well.
phil.o 22-Aug-11 11:03am    
My bad :)
You can use the RTB control in WPF.

You can change the formatting of runs in code as in this example[^]. You will have to compose paragraphs from "runs" and add them to the text box. Alternately, you could select pieces of text and apply formatting (see here for more[^]).

Cheers.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900