Editar

Compartir a través de


FontInfo.MergeWith(FontInfo) Method

Definition

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)

Parameters

f
FontInfo

A FontInfo that contains the font properties to combine.

Examples

The 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>

Remarks

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.

Note

This 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. If a property in the f parameter is not set, it will not replace the corresponding property in the current instance of the FontInfo class.

Applies to

See also