prgDevelop
prgDevelop

Reputation: 1587

How do I change the appearance of some text in a textBox?

I'm building a program similar to Messenger, sort of a chatting software.

I created a textBox to display the conversation log, and I want to make it look like this:

Nick1: Hi.

Nick2: Hello.

How do I make part of the text bold? I also want to allow users to change their own font, font-color and so on...

Thanks in advance.

Upvotes: 0

Views: 416

Answers (3)

Jon Mitchell
Jon Mitchell

Reputation: 3419

Assuming you're using WPF I'd use an ItemsControl to display the conversion. Then for each item I'd have a couple of TextBlocks one for the user name (which would be bold) and the other for the message.

Hope that helps.

Upvotes: 0

Thomas
Thomas

Reputation: 491

The best way is to use a RichTextEdit control, this control can take RTF format codes to easily format the text the way you want it.

eg.

\pard\plain\ltrpar\f0\fs14\sl240\slmult1\b\ Nick1.\par
\pard\plain\ltrpar\f0\fs14\sl240\slmult1\Hi

will show up as Nick1 Hi

Upvotes: 0

decyclone
decyclone

Reputation: 30820

Use RichTextBox if building a Windows Forms or a WPF app.

Upvotes: 3

Related Questions