FontDialog Class


FontDialog Class

Namespace

System.Windows.Forms

Creatable

Yes

Description

The FontDialog class represents a common dialog box for selecting or saving a font. The FontDialog class has properties that let you configure, display, and retrieve the results from this dialog box, from which the user selects a font.

The following list discusses the more interesting members of the FontDialog class.


Color Property

Sets or retrieves the color of the font, an instance of System.Drawing.Color. Colors can be set by their RBG value or by common names assigned to the more typical colors (like "Red").


Font Property

Sets or retrieves the font chosen by the user, an instance of System.Drawing.Font. The Font class has a number of members, including:


Bold, Italic, Strikeout, and Underline Properties

Boolean properties for basic attributes of the font.


FontFamily Property

A FontFamily object associated with the font. Use the Name property to get the name of the font family.


Name Property

Returns the face name of the font as a String.


SizeInPoints Property

Returns the size of the font, in points, as a Single.


Style Property

Returns a FontStyle constant that contains information about the style of the font. The FontStyle constants are Bold, Italic, Regular, Strikeout, and Underline, and they can be combined using a bitwise Or operation.


MaxSize, MinSize Properties

Limits the font size that the user can specify for the font.


ShowApply Property

Indicates whether the dialog box has an Apply button. The default is False.


ShowColor Property

Indicates whether the dialog box shows the font-color-choice controls. (The default is False.)


ShowEffects Property

Indicates whether the dialog box shows the strikethrough and underline options. (The default is true.)

Example

The following code displays the Font dialog box and then displays the user's choice of font family.

     Public Sub FontTest(  )        Dim selectFont As New FontDialog        selectFont.ShowDialog(  )        MsgBox(selectFont.Font.FontFamily.Name)     End Sub 

Version Differences

The public interfaces used for this FontDialog class and the related VB 6 CommonDialog control are quite different.

See Also

ColorDialog Class




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net