ComboBox.FontName 屬性 (Access)ComboBox.FontName property (Access)

您可以使用 FontName 屬性指定文字的字型在下列情況:You can use the FontName property to specify the font for text in the following situations:

  • 在表單及報表上顯示或列印控制項時。When displaying or printing controls on forms and reports.
  • 當在報表上使用 Print 方法。When using the Print method on a report.

可讀寫的 字串Read/write String.

語法Syntax

運算式字型名稱expression.FontName

_運算式_代表**ComboBox** 物件的變數。expression A variable that represents a ComboBox object.

註解Remarks

FontName 屬性設定為顯示文字的字型名稱。The FontName property setting is the name of the font that the text is displayed in.

您可以在 Visual Basic 使用控制項的預設控制項樣式或**DefaultControl** 屬性來設定此屬性的預設值。You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

對於報表,您可以設定這個屬性只能在一個事件程序或在 OnPrint 事件屬性設定值所指定的巨集。For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

字型可用與否將視您的系統及印表機而定。Font availability depends on your system and printer. 如果您選擇了一個您的系統所無法顯示或是並未安裝的字型,Windows 會以另一個類似的字型取代它。If you select a font that your system can't display or that isn't installed, Windows substitutes a similar font.

範例Example

下列範例會使用 Print 方法來顯示名為 Report1 報表上的文字。The following example uses the Print method to display text on a report named Report1. 它會使用 TextWidthTextHeight 方法來垂直和水平置中的文字。It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

Private Sub Detail_Format(Cancel As Integer, _ 
 FormatCount As Integer) 
 Dim rpt as Report 
 Dim strMessage As String 
 Dim intHorSize As Integer, intVerSize As Integer 
 
 Set rpt = Me 
 strMessage = "DisplayMessage" 
 With rpt 
 'Set scale to pixels, and set FontName and 
 'FontSize properties. 
 .ScaleMode = 3 
 .FontName = "Courier" 
 .FontSize = 24 
 End With 
 ' Horizontal width. 
 intHorSize = Rpt.TextWidth(strMessage) 
 ' Vertical height. 
 intVerSize = Rpt.TextHeight(strMessage) 
 ' Calculate location of text to be displayed. 
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2) 
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2) 
 ' Print text on Report object. 
 Rpt.Print strMessage 
End Sub

支援和意見反應Support and feedback

有關於 Office VBA 或這份文件的問題或意見反應嗎?Have questions or feedback about Office VBA or this documentation? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.