FontInfo.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.

public:
 void MergeWith(System::Web::UI::WebControls::FontInfo ^ f);
public void MergeWith (System.Web.UI.WebControls.FontInfo f);
member this.MergeWith : System.Web.UI.WebControls.FontInfo -> unit
Public Sub MergeWith (f As FontInfo)

參數

f
FontInfo

FontInfo,包含要合併的字型屬性。A FontInfo that contains the font properties to combine.

範例

下列範例示範如何使用 MergeWith 方法,將的字型屬性結合至 FontInfo 控制項的 Font 屬性 LabelThe following example demonstrates how to use the MergeWith method to combine the font properties of a FontInfo into the Font property of a Label control.

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

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

   <head>
    <title>FontInfo CopyFrom Example</title>
<script runat="server">

         void CopyFontInfo(Object sender, EventArgs e)
         {

            // Copy the FontInfo of Sample1Label to ResultLabel.
            ResultLabel.Font.CopyFrom(Sample1Label.Font);
    
            ResultLabel.Text = "Copy Result";

         }

       </script>

   </head>

   <body>

      <form id="form1" runat="server">

         <h3>FontInfo CopyFrom Example</h3>

         Click <b>Copy</b> to copy the font style of Font Sample 1 
         and display the result <br /> in the Operation Result label.
         

         <br /><br />

         <asp:Label id="Sample1Label" 
              Text="Font Sample 1" 
              Font-Names="Times New Roman" 
              Font-Italic="true" 
              Font-Strikeout="true" 
              runat="server" />

         <br /><br />

         <asp:Button id="CopyButton" 
              Text="Copy" 
              OnClick="CopyFontInfo" 
              runat="server" />

         <br /><br />

         Operation Result: <br />

         <asp:Label id="ResultLabel"
              runat="server" />

      </form>

   </body>

</html>
<%@ Page Language="VB" AutoEventWireup="True" %>

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

   <head>
    <title>FontInfo CopyFrom Example</title>
<script runat="server">

         Sub CopyFontInfo(sender As Object, e As EventArgs)

            ' Copy the FontInfo of Sample1Label to ResultLabel.
            ResultLabel.Font.CopyFrom(Sample1Label.Font)
    
            ResultLabel.Text = "Copy Result"

         End Sub

       </script>

   </head>

   <body>

      <form id="form1" runat="server">

         <h3>FontInfo CopyFrom Example</h3>

         Click <b>Copy</b> to copy the font style of Font Sample 1 
         and display the result <br /> in the Operation Result label.
         

         <br /><br />

         <asp:Label id="Sample1Label" 
              Text="Font Sample 1" 
              Font-Names="Times New Roman" 
              Font-Italic="true" 
              Font-Strikeout="true" 
              runat="server" />

         <br /><br />

         <asp:Button id="CopyButton" 
              Text="Copy" 
              OnClick="CopyFontInfo" 
              runat="server" />

         <br /><br />

         Operation Result: <br />

         <asp:Label id="ResultLabel"
              runat="server" />

      </form>

   </body>

</html>

備註

使用 MergeWith 方法,將指定之的字型屬性 FontInfoFontInfo 呼叫此方法的類別實例結合。Use the MergeWith method to combine the font properties of the specified FontInfo with the instance of the FontInfo class that this method is called from.

注意

這個方法 FontInfo 會藉由設定每個未在類別的目前實例中設定的屬性, FontInfo 以及參數之對應屬性中的值,來聯結兩個物件的屬性 fThis method joins the properties of the two FontInfo objects by setting each property that is not set in the current instance of the FontInfo class with the value in the corresponding property of the f parameter. 只會取代尚未設定的屬性。Only properties that have not been set will be replaced. 如果 f 未設定參數中的屬性,它將不會取代類別目前實例中的對應屬性 FontInfoIf a property in the f parameter is not set, it will not replace the corresponding property in the current instance of the FontInfo class.

適用於

另請參閱