FontDialog 類別

定義

提示使用者從本機電腦上安裝的字型中,選擇一種字型。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 來顯示 FontDialogThe following code example uses ShowDialog to display a FontDialog. 這段程式碼會要求已經用 TextBox 和按鈕來建立 FormThis code requires that a Form has already been created with a TextBox and button placed on it. 它也會要求已建立 fontDialog1It 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 類別的新執行個體。Initializes a new instance of the FontDialog class.

欄位

EventApply

擁有 Apply 事件。Owns the Apply event.

屬性

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

取得或設定值,指出對話方塊是否允許繪圖裝置介面 (Graphics Device Interface,GDI) 字型模擬。Gets or sets a value indicating whether the dialog box allows graphics device interface (GDI) font simulations.

AllowVectorFonts

取得或設定值,指出對話方塊是否允許選取向量字型。Gets or sets a value indicating whether the dialog box allows vector font selections.

AllowVerticalFonts

取得或設定值,指出對話方塊是否可同時顯示垂直和水平字型,或只顯示水平字型。Gets or sets a value indicating whether the dialog box displays both vertical and horizontal fonts or only horizontal fonts.

CanRaiseEvents

取得值,指出元件是否能引發事件。Gets a value indicating whether the component can raise an event.

(繼承來源 Component)
Color

取得或設定選取的字型色彩。Gets or sets the selected font color.

Container

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

(繼承來源 Component)
DesignMode

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

(繼承來源 Component)
Events

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

(繼承來源 Component)
FixedPitchOnly

取得或設定值,指出對話方塊是否只允許選取固定字幅 (Fixed-Pitch) 的字型。Gets or sets a value indicating whether the dialog box allows only the selection of fixed-pitch fonts.

Font

取得或設定選取的字型。Gets or sets the selected font.

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

取得或設定使用者可以選取的最大點數。Gets or sets the maximum point size a user can select.

MinSize

取得或設定使用者可以選取的最小點數。Gets or sets the minimum point size a user can select.

Options

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

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

取得或設定值,指出對話方塊是否包含 [套用] 按鈕。Gets or sets a value indicating whether the dialog box contains an Apply button.

ShowColor

取得或設定值,指出對話方塊是否顯示色彩選擇。Gets or sets a value indicating whether the dialog box displays the color choice.

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

取得或設定值,指出對話方塊是否顯示 [說明] 按鈕。Gets or sets a value indicating whether the dialog box displays a Help button.

Site

取得或設定 ComponentISiteGets or sets the ISite of the Component.

(繼承來源 Component)
Tag

取得或設定包含控制項相關資料的物件。Gets or sets an object that contains data about the control.

(繼承來源 CommonDialog)

方法

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(繼承來源 MarshalByRefObject)
Dispose()

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

(繼承來源 Component)
Dispose(Boolean)

釋放 Component 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the Component and optionally releases the managed resources.

(繼承來源 Component)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetLifetimeService()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(繼承來源 MarshalByRefObject)
GetService(Type)

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

(繼承來源 Component)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
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()

取得存留期服務物件,以控制這個執行個體的存留期原則。Obtains a lifetime service object to control the lifetime policy for this instance.

(繼承來源 MarshalByRefObject)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
MemberwiseClone(Boolean)

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

(繼承來源 MarshalByRefObject)
OnApply(EventArgs)

引發 Apply 事件。Raises the Apply event.

OnHelpRequest(EventArgs)

引發 HelpRequest 事件。Raises the HelpRequest event.

(繼承來源 CommonDialog)
OwnerWndProc(IntPtr, Int32, IntPtr, IntPtr)

定義為了將特定功能加入通用對話方塊中而覆寫的主控視窗 (Owner Window) 程序。Defines the owner window procedure that is overridden to add specific functionality to a common dialog box.

(繼承來源 CommonDialog)
Reset()

將所有對話方塊選項重設為預設值。Resets all dialog box options to their default values.

RunDialog(IntPtr)

指定檔案對話方塊。Specifies a file dialog box.

ShowDialog()

以預設的擁有人來執行通用對話方塊。Runs a common dialog box with a default owner.

(繼承來源 CommonDialog)
ShowDialog(IWin32Window)

以指定的擁有人來執行通用對話方塊。Runs a common dialog box with the specified owner.

(繼承來源 CommonDialog)
ToString()

擷取字串,其中包含對話方塊中選取之目前字型的名稱。Retrieves a string that includes the name of the current font selected in the dialog box.

事件

Apply

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

Disposed

當此元件由 Dispose() 方法的呼叫處置時發生。Occurs when the component is disposed by a call to the Dispose() method.

(繼承來源 Component)
HelpRequest

發生於使用者按一下通用對話方塊上的 [說明] 按鈕時。Occurs when the user clicks the Help button on a common dialog box.

(繼承來源 CommonDialog)

適用於

另請參閱