ComboBox.FontSize 屬性 (Access)

在下列情況下,使用 FontSize 屬性來指定文字的點大小:

  • 在表單及報表上顯示或列印控制項時。
  • 當在報表上使用 Print 方法。

可讀寫的 Integer

語法

運算式FontSize

表達 代表 ComboBox 物件的變數。

註解

FontSize 屬性使用下列設定值。

設定 描述
8 (除了命令按鈕以外所有報表及控制項的預設值) 文字是以 8 點的類型顯示。
10 (命令按鈕的預設值) 文字是以 10 點的類型顯示。
其他大小 文字以指定大小顯示。

您可以使用控制項的預設控制項樣式或 Visual Basic 中的 DefaultControl 屬性來設定這個屬性的預設值。

對於報表,您可以設定這個屬性只能在一個事件程序或在 OnPrint 事件屬性設定值所指定的巨集。

在 Visual Basic 中您要使用的字型所需的大小的數值運算式等於設定 FontSize 屬性。 FontSize 屬性的值可以是介於 1 到 127 個 (含) 之間。

範例

下列範例會使用 Print 方法來顯示名為 Report1 報表上的文字。 它會使用 TextWidthTextHeight 方法來垂直和水平置中的文字。

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

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應