RickTextBox font properties

  • Thread starter Thread starter Adam Honek
  • Start date Start date
A

Adam Honek

Hello,

I have a rich textbox on my form and I want the user to be able
to select the font properties via the font dialog box.

1) How do I bring up the font dialog box in the code?
2) How do I make the settings on it affect the rich textbox in question?

Many thanks,
Adam Honek
 
Adam Honek said:
I have a rich textbox on my form and I want the user to be able
to select the font properties via the font dialog box.

1) How do I bring up the font dialog box in the code?
2) How do I make the settings on it affect the rich textbox in question?

Add a richtextbox and a fontdialog component to your form, then place the
code below in a button's 'Click' event handler:

\\\
If Me.FontDialog1.ShowDialog() = DialogResult.OK Then
Me.RichTextBox1.SelectionFont = Me.FontDialog1.Font
End If
///
 
Thanks for this.

It works but there is only 1 bug.

It seems that the rich text box reverts to its original font the second time
something is displayed in it.

So for example we send "blahblah" to it and then send "some text" the latter
will appear in the original font.

Adam
 
Adam Honek said:
It seems that the rich text box reverts to its original font the second
time something is displayed in it.

So for example we send "blahblah" to it and then send "some text" the
latter will appear in the original font.

Either assign the selected font to the richtextbox's 'Font' property or
select the whole text and apply the font.
 
Right done that and it works now.

The only problem now would be that the font affects all the text instead of
just
the own users text.

The app is a kind of chat app allowing admins to communicate between each
other.

Thanks,
Adam
 
Back
Top