Hello World,
I have a Richtext box and have a textbox. When somebody types in something in the textbox, I want that to be the font of the Richtext box. I tried Richtextbox1.font.name = "Times New Roman" but it gives an error line, and says "Property "Name" is 'Readonly'??
How do i set the font name. Richtextbox1.font.name is a get type property. I need a set type. Help!
Dhruv(BattleGuard)
THX
Comments
Here's a possibility...
RichTextBox1.Font = New Font(TextBox1.Text, 10)
Obviously you can put in whatever you want instead of 10 but hopefully this helps. There are multiple constructors available that allow you to also include the FontStyle, etc. if you like.
Chris
: Hello World,
: I have a Richtext box and have a textbox. When somebody types in something in the textbox, I want that to be the font of the Richtext box. I tried Richtextbox1.font.name = "Times New Roman" but it gives an error line, and says "Property "Name" is 'Readonly'??
: How do i set the font name. Richtextbox1.font.name is a get type property. I need a set type. Help!
:
: Dhruv(BattleGuard)
:
: THX
:
I have four checkboxes and they're labeled - bold, italics, underline, strikeout. I want the text in the richtext box to be bold whenever somebody presses that button and bold is checked. I got how to do one of each, but if somebody checks italics and bold, how do i do that??? Then italics, bold and underline, and so on???
Dhruv(BattleGuard)
THX
: Hello,
:
: Here's a possibility...
:
: RichTextBox1.Font = New Font(TextBox1.Text, 10)
:
: Obviously you can put in whatever you want instead of 10 but hopefully this helps. There are multiple constructors available that allow you to also include the FontStyle, etc. if you like.
:
: Chris
:
:
: : Hello World,
: : I have a Richtext box and have a textbox. When somebody types in something in the textbox, I want that to be the font of the Richtext box. I tried Richtextbox1.font.name = "Times New Roman" but it gives an error line, and says "Property "Name" is 'Readonly'??
: : How do i set the font name. Richtextbox1.font.name is a get type property. I need a set type. Help!
: :
: : Dhruv(BattleGuard)
: :
: : THX
: :
:
:
Here's a possibility....
1. On your form
Add five checkboxes:
chkBold, chkItalic, chkUnderline, chkStrikeout, chkRegular
2. Add a Function
---------------
Private Function SetFontStyle() As FontStyle
Dim fs As FontStyle
'Check User Selection (user selects 0 or more options)
fs = FontStyle.Regular 'Default
If chkBold.Checked Then
fs = fs Or FontStyle.Bold 'Or allows you to combine FontStyles
End If
If chkUnderline.Checked Then
fs = fs Or FontStyle.Underline
End If
If chkStrikeout.Checked Then
fs = fs Or FontStyle.Strikeout
End If
If chkItalic.Checked Then
fs = fs Or FontStyle.Italic
End If
Return fs 'If nothing has been checked fs = FontStyle.Regular
End Function
3. When setting the Font to the RichTextBox
RichTextBox1.Font = New Font(TextBox1.Text, 10, SetFontStyle())
Hope this helps,
Chris