FontFamily.GetCellAscent(FontStyle) 方法

定義

傳回指定的樣式之 FontFamily 的方格上移 (單位為設計單位)。

public:
 int GetCellAscent(System::Drawing::FontStyle style);
public int GetCellAscent (System.Drawing.FontStyle style);
member this.GetCellAscent : System.Drawing.FontStyle -> int
Public Function GetCellAscent (style As FontStyle) As Integer

參數

style
FontStyle

FontStyle,包含字型的樣式資訊。

傳回

使用指定之 FontStyle 的這個 FontFamily 的方格上移。

範例

下列程式代碼範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse,這是事件處理程序的參數Paint。 此程式碼會執行下列動作:

  • 建立 FontFamily

  • 取得該字型系列的數據格向中。

  • 以文字方式將儲存格的值繪製到畫面上。

public:
   void GetCellAscent_Example( PaintEventArgs^ e )
   {
      // Create a FontFamily object.
      FontFamily^ ascentFontFamily = gcnew FontFamily( "arial" );

      // Get the cell ascent of the font family in design units.
      int cellAscent = ascentFontFamily->GetCellAscent( FontStyle::Regular );

      // Draw the result as a string to the screen.
      e->Graphics->DrawString( String::Format( "ascentFontFamily.GetCellAscent() returns {0}.", cellAscent ),
            gcnew System::Drawing::Font( ascentFontFamily,16 ), Brushes::Black, PointF(0,0) );
   }
public void GetCellAscent_Example(PaintEventArgs e)
{
    // Create a FontFamily object.
    FontFamily ascentFontFamily = new FontFamily("arial");
             
    // Get the cell ascent of the font family in design units.
    int cellAscent = ascentFontFamily.GetCellAscent(FontStyle.Regular);
             
    // Draw the result as a string to the screen.
    e.Graphics.DrawString(
        "ascentFontFamily.GetCellAscent() returns " + cellAscent.ToString() + ".",
        new Font(ascentFontFamily, 16),
        Brushes.Black,
        new PointF(0, 0));
}
Public Sub GetCellAscent_Example(ByVal e As PaintEventArgs)

    ' Create a FontFamily object.
    Dim ascentFontFamily As New FontFamily("arial")

    ' Get the cell ascent of the font family in design units.
    Dim cellAscent As Integer = _
    ascentFontFamily.GetCellAscent(FontStyle.Regular)

    ' Draw the result as a string to the screen.
    e.Graphics.DrawString("ascentFontFamily.GetCellAscent() returns " _
    & cellAscent.ToString() & ".", New Font(ascentFontFamily, 16), _
    Brushes.Black, New PointF(0, 0))
End Sub

適用於

另請參閱