This documentation is archived and is not being maintained.

FontInfo.MergeWith Method

Combines the font properties of the specified FontInfo with the instance of the FontInfo class that this method is called from.

[Visual Basic]
Public Sub MergeWith( _
   ByVal f As FontInfo _
)
[C#]
public void MergeWith(
 FontInfo f
);
[C++]
public: void MergeWith(
 FontInfo* f
);
[JScript]
public function MergeWith(
   f : FontInfo
);

Parameters

f
A FontInfo that contains the font properties to combine.

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.

Example

[Visual Basic, C#] 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.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>

<html>

   <head>

      <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 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-Name="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>

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

<html>

   <head>

      <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 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-Name="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>

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

FontInfo Class | FontInfo Members | System.Web.UI.WebControls Namespace | CopyFrom | Font

Show: