Labels control Striking off

TexasP

New member
Joined
Jul 14, 2007
Messages
4
Programming Experience
1-3
hi

I have searched google and tried different methods but I still can't manage to find the correct one

how do I have a striked off label?

like hehe <-- striked off
 
"Striked out" perhaps? Click the Font property and check "Strikeout" checkbox in the font dialog (or expand the Font sub-properties and set Strikeout to True).
 
You have to create a new font and set the style, then assign it to label font:
VB.NET:
Label1.Font = New Font(Label1.Font, FontStyle.Strikeout)
To combine styles you use bitwise operators, for example adding strikeout to existing font styles (it could be bold italic and you want to add strikeout) you first grab the current styles:
VB.NET:
Dim styles As FontStyle = Label1.Font.Style
then use the Or operator:
VB.NET:
Label1.Font = New Font(Label1.Font, styles Or FontStyle.Strikeout)
Here's how to remove the strikeout while preservering the other current styles set:
VB.NET:
Label1.Font = New Font(Label1.Font, styles And Not FontStyle.Strikeout)
Of course you don't need to keep the styles in a variable, in some cases you do, but you could also write like this:
VB.NET:
Label1.Font = New Font(Label1.Font, Label1.Font.Style Or FontStyle.Strikeout)
 
Back
Top