FontSize 屬性

此頁(yè)沒(méi)有內(nèi)容條目
內(nèi)容

expandtri全部顯示

使用 ForeSize 屬性可以在以下情況中為文本指定值大小。

?在顯示或打印窗體報(bào)表中的控件時(shí)。

 

?在報(bào)表中使用 Print 方法時(shí)。

Integer 型,可讀/寫(xiě)。

expression.FontSize

expression     必需。返回“應(yīng)用于”列表中的一個(gè)對(duì)象的表達(dá)式。

說(shuō)明

FontSize 屬性使用以下的設(shè)置:

設(shè)置

說(shuō)明

8

(除了命令按鈕之外所有報(bào)表及控件的默認(rèn)值)文本為 8 磅大小。

10

(命令按鈕的默認(rèn)值)文本為 10 磅大小。

其他大小

文本以指定大小顯示。

 

注釋  對(duì)于窗體及報(bào)表上的控件,可以使用屬性表、Visual Basic 來(lái)設(shè)置該屬性。

也可以單擊“格式(窗體/報(bào)表)”工具欄上的“字號(hào)”框來(lái)設(shè)置該屬性。

使用控件的默認(rèn)控件樣式或在 Visual Basic 中使用 DefaultControl 可以設(shè)置該屬性的默認(rèn)值。

對(duì)于報(bào)表,只能在 OnPrint 事件屬性設(shè)置所指定的事件過(guò)程或宏中設(shè)置該屬性。

在 Visual Basic 中,可以使用屬性等于所需字號(hào)的數(shù)字表達(dá)式設(shè)置 FontSize。FontSize 屬性設(shè)置值介于 1 和 127 之間,包含 1 與 127。

示例

以下示例使用 Print 方法來(lái)顯示名為“報(bào)表1”的報(bào)表上的文本。它使用 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