FontInfo 類別

定義

封裝文字的字型屬性。Encapsulates the font properties of text. 此類別無法獲得繼承。This class cannot be inherited.

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 ,以指定控制項的字型屬性 LabelThe following code example demonstrates how to modify the properties of a FontInfo object programmatically to specify the font properties for a Label control.

<%@ 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 類別來封裝文字的字型屬性。Use the FontInfo class to encapsulate the font properties of text. 您可以指定字型名稱和字型大小。You can specify the font name and font size. 您也可以指定字型的樣式是粗體、斜體、overlined、刪除線或加上底線。You can also specify whether the style of the font is bold, italic, overlined, strikethrough, or underlined.

此類別通常用於需要字型資訊之類別的屬性,例如 Font 類別的屬性 WebControlThis class is commonly used in a property for a class that requires font information, such as the Font property of the WebControl class.

注意

這個類別沒有公用的函式。This class does not have a public constructor. 無法直接建立類別的新實例。A new instance of the class cannot be created directly.

屬性

Bold

取得或設定值,指出字型是否為粗體。Gets or sets a value that indicates whether the font is bold.

Italic

取得或設定值,指出字型是否為斜體。Gets or sets a value that indicates whether the font is italic.

Name

取得或設定主要字型名稱。Gets or sets the primary font name.

Names

取得或設定字型名稱的已排序陣列。Gets or sets an ordered array of font names.

Overline

取得或設定值,指出字型是否為加頂線。Gets or sets a value that indicates whether the font is overlined.

Size

取得或設定字型大小。Gets or sets the font size.

Strikeout

取得或設定值,指出字型是否為加刪除線。Gets or sets a value that indicates whether the font is strikethrough.

Underline

取得或設定值,指出字型是否為加底線。Gets or sets a value that indicates whether the font is underlined.

方法

ClearDefaults()

將所有 FontInfo 屬性重設為未設定的狀態,並清除檢視狀態。Resets all FontInfo properties to the unset state and clears the view state.

CopyFrom(FontInfo)

將指定 FontInfo 的字型屬性複製到呼叫此方法的 FontInfo 類別執行個體。Duplicates the font properties of the specified FontInfo into the instance of the FontInfo class that this method is called from.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
MergeWith(FontInfo)

合併所指定 FontInfo 的字型屬性與呼叫此方法之 FontInfo 類別的執行個體。Combines the font properties of the specified FontInfo with the instance of the FontInfo class that this method is called from.

ShouldSerializeNames()

判斷是否應該保存 Names 屬性。Determines whether the Names property should be persisted.

ToString()

傳回字串,其中包含 FontInfo 類別執行個體的字型名稱及大小。Returns a string that contains the font name and size for an instance of the FontInfo class.

適用於

另請參閱