FontInfo 類別

定義

封裝文字的字型屬性。 此類別無法獲得繼承。

public ref class FontInfo sealed
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
public sealed class FontInfo
[<System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))>]
type FontInfo = class
Public NotInheritable Class FontInfo
繼承
FontInfo
屬性

範例

下列程式碼範例示範如何以程式設計方式修改物件的屬性 FontInfo ,以指定控制項的 Label 字型屬性。

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  void Page_Load(object sender, EventArgs e)
  {
    // When the page loads, set the myLabel Label control's FontInfo properties.
    // Note that myLabel.Font is a FontInfo object.
    
    myLabel.Font.Bold = true;
    myLabel.Font.Italic = false;
    myLabel.Font.Name = "verdana";
    myLabel.Font.Overline = false;
    myLabel.Font.Size = 10;
    myLabel.Font.Strikeout = false;
    myLabel.Font.Underline = true;
    
    // Write information on the FontInfo object to the myLabel label.
    myLabel.Text = myLabel.Font.ToString();
    
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>FontInfo Example</title>
</head>
  <body>
    <form id="form1" runat="server">
    <h3>FontInfo Example</h3>
      <asp:Label id="myLabel" 
        runat="server" >
      </asp:Label>
    </form>
  </body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
  
    ' When the page loads, set the myLabel Label control's FontInfo properties.
    ' Note that myLabel.Font is a FontInfo object.
    
    myLabel.Font.Bold = True
    myLabel.Font.Italic = False
    myLabel.Font.Name = "verdana"
    myLabel.Font.Overline = False
    myLabel.Font.Size = 10
    myLabel.Font.Strikeout = False
    myLabel.Font.Underline = True
    
    ' Write information on the FontInfo object to the myLabel label.
    myLabel.Text = myLabel.Font.ToString()
    
  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>FontInfo Example</title>
</head>
  <body>
    <form id="form1" runat="server">
    <h3>FontInfo Example</h3>
      <asp:Label id="myLabel" 
        runat="server" >
      </asp:Label>
    </form>
  </body>
</html>

備註

使用 類別 FontInfo 來封裝文字的字型屬性。 您可以指定字型名稱和字型大小。 您也可以指定字型的樣式是粗體、斜體、斜體、底線、刪除線或底線。

這個類別通常用於需要字型資訊的類別屬性,例如 Font 類別的 WebControl 屬性。

注意

這個類別沒有公用建構函式。 無法直接建立 類別的新實例。

屬性

Bold

取得或設定值,指出字型是否為粗體。

Italic

取得或設定值,指出字型是否為斜體。

Name

取得或設定主要字型名稱。

Names

取得或設定字型名稱的已排序陣列。

Overline

取得或設定值,指出字型是否為加頂線。

Size

取得或設定字型大小。

Strikeout

取得或設定值,指出字型是否為加刪除線。

Underline

取得或設定值,指出字型是否為加底線。

方法

ClearDefaults()

將所有 FontInfo 屬性重設為未設定的狀態,並清除檢視狀態。

CopyFrom(FontInfo)

將指定 FontInfo 的字型屬性複製到呼叫此方法的 FontInfo 類別執行個體。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MergeWith(FontInfo)

合併所指定 FontInfo 的字型屬性與呼叫此方法之 FontInfo 類別的執行個體。

ShouldSerializeNames()

判斷是否應該保存 Names 屬性。

ToString()

傳回字串,其中包含 FontInfo 類別執行個體的字型名稱及大小。

適用於

另請參閱