FontDialog FontDialog FontDialog FontDialog Class

定義

提示使用者從本機電腦上安裝的字型中,選擇一種字型。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
繼承

範例

下列程式碼範例會ShowDialog使用來FontDialog顯示。The following code example uses ShowDialog to display a FontDialog. 此程式Form代碼要求已建立TextBox , 並在其上放置和按鈕。This code requires that a Form has already been created with a TextBox and button placed on it. 它也會要求fontDialog1已建立。It also requires that the fontDialog1 has been created. Font包含大小資訊, 而不是色彩資訊。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

備註

必須叫用ShowDialog繼承的成員, 才能建立這個特定的通用對話方塊。The inherited member ShowDialog must be invoked to create this specific common dialog box. HookProc可以覆寫以執行特定的對話方塊勾點功能。HookProc can be overridden to implement specific dialog box hook functionality.

當您建立的實例FontDialog時, 部分的讀取/寫入屬性會設定為初始值。When you create an instance of FontDialog, some of the read/write properties are set to initial values. 如需這些值的清單, 請參閱FontDialog函數。For a list of these values, see the FontDialog constructor.

建構函式

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

初始化 FontDialog 類別的新執行個體。Initializes a new instance of the FontDialog class.

欄位

EventApply EventApply EventApply EventApply

擁有 Apply 事件。Owns the Apply event.

屬性

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

取得或設定值,指出對話方塊是否允許繪圖裝置介面 (Graphics Device Interface,GDI) 字型模擬。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

取得包含 IContainerComponentGets the IContainer that contains the Component.

(Inherited from Component)
DesignMode DesignMode DesignMode DesignMode

取得值,指出 Component 目前是否處於設計模式。Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
Events Events Events Events

取得附加在這個 Component 上的事件處理常式清單。Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
FixedPitchOnly FixedPitchOnly FixedPitchOnly FixedPitchOnly

取得或設定值,指出對話方塊是否只允許選取固定字幅 (Fixed-Pitch) 的字型。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

取得值來初始化 FontDialogGets values to initialize the FontDialog.

ScriptsOnly ScriptsOnly ScriptsOnly ScriptsOnly

取得或設定值,指出對話方塊是否允許選取所有非 OEM、Symbol 和 ANSI 字元集的字型。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

取得或設定 ComponentISiteGets 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)

方法

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

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。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()

釋放 Component 所使用的所有資源。Releases all resources used by the Component.

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

釋放 Component 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。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()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。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)

傳回表示 Component 或其 Container 所提供之服務的物件。Returns an object that represents a service provided by the Component or by its Container.

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

取得目前執行個體的 TypeGets 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()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

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

建立目前 MarshalByRefObject 物件的淺層複本。Creates a shallow copy of the current MarshalByRefObject object.

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

引發 Apply 事件。Raises the Apply event.

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

引發 HelpRequest 事件。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)

定義為了將特定功能加入到通用對話方塊中而覆寫的主控視窗 (Owner Window) 程序。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.

事件

Apply Apply Apply Apply

發生於使用者按一下 [字型] 對話方塊中的 [套用] 按鈕時。Occurs when the user clicks the Apply button in the font dialog box.

Disposed Disposed Disposed Disposed

當此元件由 Dispose() 方法的呼叫處置時發生。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)

適用於

另請參閱