This documentation is archived and is not being maintained.

FontInfo.CopyFrom Method

Duplicates the font properties of the specified FontInfo into the instance of the FontInfo class that this method is called from.

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

Parameters

f
A FontInfo that contains the font properties to duplicate.

Remarks

Use the CopyFrom method to duplicate the font properties of the specified FontInfo into the instance of the FontInfo class that this method is called from.

CAUTION   All properties in the current instance of the FontInfo class will be replaced by the associated property in the f parameter.

Example

[Visual Basic, C#] The following example demonstrates how to use the CopyFrom method to duplicate 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 | MergeWith | Font

Show: