How to make the text 'Bold'

R

Radith Silva

I have the following code:

Private Sub Bold(ByVal sender As Object, ByVal e As System.EventArgs)
Handles mnuFileBold.Click

If mnuFileBold.Checked = True Then
mnuFileBold.Checked = False
ElseIf mnuFileBold.Checked = False Then
mnuFileBold.Checked = True
End If

If mnuFileBold.Checked = True Then
Label1.Text = "Radeesha Silva"
Else
Label1.Text = "Radith Silva"
End If

End Sub

Instead of Changing the Text of the Label I want to make the original
text of the label to appear in Bold. I have tried 'Label1.Font.Bold' but
that returns the error 'Property access must assign to the property or
use its value.'


All replies welcome

Thanx. Radith Silva


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
O

One Handed Man \( OHM - Terry Burns \)

Dim f As New Font(TextBox1.Font.FontFamily, TextBox1.Font.Size,
FontStyle.Bold)

TextBox1.Font = f


--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 
B

BluDog

Instead of Changing the Text of the Label I want to make the original
text of the label to appear in Bold. I have tried 'Label1.Font.Bold' but
that returns the error 'Property access must assign to the property or
use its value.'

Try this:

<code>

Private Sub CheckBox1_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
CheckBox1.CheckedChanged

Dim f As Font

If CheckBox1.Checked Then
f = New Font(Label1.Font, FontStyle.Bold)
Else
f = New Font(Label1.Font, FontStyle.Regular)
End If

Label1.Font = f

End Sub

</code>

Hope this helps

Blu.
 
J

Jason James

Radith,

Hope this helps,

Jason.

If Label1.Font.Bold = False Then
Label1.Font = New Font("Microsoft Sans Serif", 12, FontStyle.Bold,
GraphicsUnit.Pixel)
Else
Label1.Font = New Font("Microsoft Sans Serif", 12,
FontStyle.Regular, GraphicsUnit.Pixel)
End If
 
T

The Grim Reaper

Try this;

Private Sub Bold(ByVal sender As Object, ByVal e As System.EventArgs)
Handles mnuFileBold.Click
mnuFileBold.Checked = Not mnuFileBold.Checked
If mnuFileBold.Checked Then
Label1.Font.Bold = True
Else
Label1.Font.Bold = False
End If
End Sub
_____________________________
The Grim Reaper
 
H

Herfried K. Wagner [MVP]

* Radith Silva said:
Instead of Changing the Text of the Label I want to make the original
text of the label to appear in Bold. I have tried 'Label1.Font.Bold' but
that returns the error 'Property access must assign to the property or
use its value.'

\\\
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
Me.Label1.Font = New Font(Me.Label1.Font, IIf(Me.CheckBox1.Checked, FontStyle.Bold, FontStyle.Regular))
End Sub
///
 
C

Cor Ligthert

Hi Radith,

Because I find that one from Herfried is so terrible with that IIF, I add as
well one. (It was a nice try from Herfried to do something else, however I
am sure that he nock on his head when he sees this one)

\\\
Me.Label1.Font = New Font(Me.Label1.Font, Me.Label1.Font.Style Or
FontStyle.Bold)
///
:)

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top