FontBold, FontItalic, FontStrikethru, FontTransparent, FontUnderline Properties

See Also7SR70V2                 Example2J9I3AA>Low

Apply To

Form14TJ2LN, check box9P3BU5, combo box1YZXFF6, command buttonXJSPC0, common dialog1H1HYJI, data control2E1FEX3, directory list boxO9U5A0, drive list box5WJO0PW, file list box1M6S8UX, frame1KX6ZP8, grid2VGT0PT, label3MNIZ8D, list boxG11UCK, option buttonJYBO08, picture box31MYIWX, Printer objectCBQUDQ, text boxYPYZDG.

Description

Determine font styles in the following formats:  FontBold, FontItalic, FontStrikethru, and FontUnderline.  FontTransparent determines whether background text or graphics are included with the characters in a particular font; FontTransparent applies only to forms, picture boxes, and the Printer object.

Usage

{ [form.][control.]|Printer.}FontBold[ = boolean ]

{ [form.][control.]|Printer.}FontItalic[ = boolean ]

{ [form.][control.]|Printer.}FontStrikethru[ = boolean ]

{ [form.][picturebox.]|Printer.}FontTransparent[ = boolean ]

{ [form.][control.]|Printer.}FontUnderline[ = boolean ]

Setting

The settings for the FontBold, FontItalic, FontStrikethru, FontTransparent, and FontUnderline properties are:

Setting     Description

 

True         (Default for FontBold (except with the common dialog control) and FontTransparent) Turns on the formatting in that style.  Setting FontTransparent to True permits background graphics or text to show through the characters in a font.

False        (Default for FontItalic, FontStrikethru, and FontUnderline; and FontBold with the common dialog control) Turns off the formatting in that style.  Setting FontTransparent to False masks out existing background graphics or text.

 

Remarks

Use these font properties to format text, either at design time using the Properties window or at run time using code.  For forms, picture boxes, and the Printer object, setting these properties does not affect graphics or print output already drawn to a form, picture box, or Printer object.  For all other controls, font changes take effect on the screen immediately.

To use these properties with the common dialog control, the CF_EFFECTS flag must be set.

 

Note   Fonts available in Visual Basic vary according to your system configuration, display devices, and printing devices.  Font-related properties can be set only to values for which actual fonts exist.

In general, you should change the FontNameB3RMO3 property before you set size and style attributes with the FontSizeB3WV13, FontBold, FontItalic, FontStrikethru, FontTransparent, and FontUnderline properties.  However, when you set TrueType fonts to smaller than 8 points, you should set the point size with the FontSize property, then set the FontName property, and then set the size again with the FontSize property.  The Windows environment uses a different font for TrueType fonts that are smaller than 8 points.

 

Data Type

IntegerDOKXHY (Boolean)


See Also

Help:

TextHeight Method4OFKMKO

TextWidth Method8ZWV014

 

Programmer's Guide:

Chapter 16, "Displaying and Printing Information"


FontBold, FontItalic, FontStrikethru, FontTransparent, FontUnderline Properties Example

The example puts text on a form in one of two combinations of styles with each mouse click.  To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.

Sub Form_Click ()
  FontStrikethru = Not FontStrikethru    ' Toggle strikethru.
  FontItalic = Not FontStrikethru        ' Toggle font style.
  Print "Now is the time!"               ' Print some text.
End Sub