FontDialog FontDialog FontDialog FontDialog Class

Definition

Prompts the user to choose a font from among those installed on the local computer.

public ref class FontDialog : System::Windows::Forms::CommonDialog
public class FontDialog : System.Windows.Forms.CommonDialog
type FontDialog = class
    inherit CommonDialog
Public Class FontDialog
Inherits CommonDialog
Inheritance

Examples

The following code example uses ShowDialog to display a FontDialog. This code requires that a Form has already been created with a TextBox and button placed on it. It also requires that the fontDialog1 has been created. The Font contains the size information but not the color information.

private:
   void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      fontDialog1->ShowColor = true;

      fontDialog1->Font = textBox1->Font;
      fontDialog1->Color = textBox1->ForeColor;

      if ( fontDialog1->ShowDialog() != ::DialogResult::Cancel )
      {
         textBox1->Font = fontDialog1->Font;
         textBox1->ForeColor = fontDialog1->Color;
      }
   }
private void button1_Click(object sender, System.EventArgs e)
 {
    fontDialog1.ShowColor = true;

    fontDialog1.Font = textBox1.Font;
    fontDialog1.Color = textBox1.ForeColor;

    if(fontDialog1.ShowDialog() != DialogResult.Cancel )
    {
       textBox1.Font = fontDialog1.Font ;
       textBox1.ForeColor = fontDialog1.Color;
    }
 }
 
Private Sub button1_Click(sender As Object, e As System.EventArgs)
    fontDialog1.ShowColor = True

    fontDialog1.Font = textBox1.Font
    fontDialog1.Color = textBox1.ForeColor

    If fontDialog1.ShowDialog() <> DialogResult.Cancel Then
        textBox1.Font = fontDialog1.Font
        textBox1.ForeColor = fontDialog1.Color
    End If
End Sub 'button1_Click

Remarks

The inherited member ShowDialog must be invoked to create this specific common dialog box. HookProc can be overridden to implement specific dialog box hook functionality.

When you create an instance of FontDialog, some of the read/write properties are set to initial values. For a list of these values, see the FontDialog constructor.

Constructors

FontDialog() FontDialog() FontDialog() FontDialog()

Initializes a new instance of the FontDialog class.

Fields

EventApply EventApply EventApply EventApply

Owns the Apply event.

Properties

AllowScriptChange AllowScriptChange AllowScriptChange AllowScriptChange

Gets or sets a value indicating whether the user can change the character set specified in the Script combo box to display a character set other than the one currently displayed.

AllowSimulations AllowSimulations AllowSimulations AllowSimulations

Gets or sets a value indicating whether the dialog box allows graphics device interface (GDI) font simulations.

AllowVectorFonts AllowVectorFonts AllowVectorFonts AllowVectorFonts

Gets or sets a value indicating whether the dialog box allows vector font selections.

AllowVerticalFonts AllowVerticalFonts AllowVerticalFonts AllowVerticalFonts

Gets or sets a value indicating whether the dialog box displays both vertical and horizontal fonts or only horizontal fonts.

CanRaiseEvents CanRaiseEvents CanRaiseEvents CanRaiseEvents

Gets a value indicating whether the component can raise an event.

(Inherited from Component)
Color Color Color Color

Gets or sets the selected font color.

Container Container Container Container

Gets the IContainer that contains the Component.

(Inherited from Component)
DesignMode DesignMode DesignMode DesignMode

Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
Events Events Events Events

Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
FixedPitchOnly FixedPitchOnly FixedPitchOnly FixedPitchOnly

Gets or sets a value indicating whether the dialog box allows only the selection of fixed-pitch fonts.

Font Font Font Font

Gets or sets the selected font.

FontMustExist FontMustExist FontMustExist FontMustExist

Gets or sets a value indicating whether the dialog box specifies an error condition if the user attempts to select a font or style that does not exist.

MaxSize MaxSize MaxSize MaxSize

Gets or sets the maximum point size a user can select.

MinSize MinSize MinSize MinSize

Gets or sets the minimum point size a user can select.

Options Options Options Options

Gets values to initialize the FontDialog.

ScriptsOnly ScriptsOnly ScriptsOnly ScriptsOnly

Gets or sets a value indicating whether the dialog box allows selection of fonts for all non-OEM and Symbol character sets, as well as the ANSI character set.

ShowApply ShowApply ShowApply ShowApply

Gets or sets a value indicating whether the dialog box contains an Apply button.

ShowColor ShowColor ShowColor ShowColor

Gets or sets a value indicating whether the dialog box displays the color choice.

ShowEffects ShowEffects ShowEffects ShowEffects

Gets or sets a value indicating whether the dialog box contains controls that allow the user to specify strikethrough, underline, and text color options.

ShowHelp ShowHelp ShowHelp ShowHelp

Gets or sets a value indicating whether the dialog box displays a Help button.

Site Site Site Site

Gets or sets the ISite of the Component.

(Inherited from Component)
Tag Tag Tag Tag

Gets or sets an object that contains data about the control.

(Inherited from CommonDialog)

Methods

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

Releases all resources used by the Component.

(Inherited from Component)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Releases the unmanaged resources used by the Component and optionally releases the managed resources.

(Inherited from Component)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
HookProc(IntPtr, Int32, IntPtr, IntPtr) HookProc(IntPtr, Int32, IntPtr, IntPtr) HookProc(IntPtr, Int32, IntPtr, IntPtr) HookProc(IntPtr, Int32, IntPtr, IntPtr)

Specifies the common dialog box hook procedure that is overridden to add specific functionality to a common dialog box.

InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
OnApply(EventArgs) OnApply(EventArgs) OnApply(EventArgs) OnApply(EventArgs)

Raises the Apply event.

OnHelpRequest(EventArgs) OnHelpRequest(EventArgs) OnHelpRequest(EventArgs) OnHelpRequest(EventArgs)

Raises the HelpRequest event.

(Inherited from CommonDialog)
OwnerWndProc(IntPtr, Int32, IntPtr, IntPtr) OwnerWndProc(IntPtr, Int32, IntPtr, IntPtr) OwnerWndProc(IntPtr, Int32, IntPtr, IntPtr) OwnerWndProc(IntPtr, Int32, IntPtr, IntPtr)

Defines the owner window procedure that is overridden to add specific functionality to a common dialog box.

(Inherited from CommonDialog)
Reset() Reset() Reset() Reset()

Resets all dialog box options to their default values.

RunDialog(IntPtr) RunDialog(IntPtr) RunDialog(IntPtr) RunDialog(IntPtr)

Specifies a file dialog box.

ShowDialog() ShowDialog() ShowDialog() ShowDialog()

Runs a common dialog box with a default owner.

(Inherited from CommonDialog)
ShowDialog(IWin32Window) ShowDialog(IWin32Window) ShowDialog(IWin32Window) ShowDialog(IWin32Window)

Runs a common dialog box with the specified owner.

(Inherited from CommonDialog)
ToString() ToString() ToString() ToString()

Retrieves a string that includes the name of the current font selected in the dialog box.

Events

Apply Apply Apply Apply

Occurs when the user clicks the Apply button in the font dialog box.

Disposed Disposed Disposed Disposed

Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)
HelpRequest HelpRequest HelpRequest HelpRequest

Occurs when the user clicks the Help button on a common dialog box.

(Inherited from CommonDialog)

Applies to

See Also