Compartir a través de


FontInfo.CopyFrom(FontInfo) Método

Definición

Duplica las propiedades de fuente del objeto FontInfo especificado en la instancia de la clase FontInfo desde la que se llama a este método.

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

Parámetros

f
FontInfo

FontInfo que contiene las propiedades de fuente que se van a duplicar.

Ejemplos

En el ejemplo siguiente se muestra cómo usar el CopyFrom método para duplicar las propiedades de fuente de en FontInfo la Font propiedad de un 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>

Comentarios

Use el CopyFrom método para duplicar las propiedades de fuente del especificado FontInfo en la instancia de la clase desde la FontInfo que se llama a este método.

Precaución

Todas las propiedades de la instancia actual de la FontInfo clase se reemplazarán por la propiedad asociada en el f parámetro .

Cuando se registra un estilo mediante RegisterStyley, a continuación, se copia mediante Style.CopyFrom(Style), solo se copia la CssClass propiedad en el destino, no todas las propiedades individuales. Por lo tanto, si usa FontInfo.CopyFrom(FontInfo) para copiar la información de fuente de la Font propiedad de un Style que está registrado, no obtendrá la configuración individual de la fuente del estilo.

Se aplica a

Consulte también