FontInfo.MergeWith(FontInfo) Méthode

Définition

Combine les propriétés de police du FontInfo spécifié avec l’instance de la classe FontInfo à partir de laquelle cette méthode est appelée.

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)

Paramètres

f
FontInfo

Classe FontInfo qui contient les propriétés de police à combiner.

Exemples

L’exemple suivant montre comment utiliser la MergeWith méthode pour combiner les propriétés de police d’un FontInfo dans la Font propriété d’un Label contrôle.

<%@ 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>

Remarques

Utilisez la MergeWith méthode pour combiner les propriétés de police du spécifié FontInfo avec l’instance de la FontInfo classe à partir de laquelle cette méthode est appelée.

Remarque

Cette méthode joint les propriétés des deux FontInfo objets en définissant chaque propriété qui n’est pas définie dans l’instance actuelle de la classe avec la FontInfo valeur dans la propriété correspondante du f paramètre. Seules les propriétés qui n’ont pas été définies seront remplacées. Si une propriété dans le f paramètre n’est pas définie, elle ne remplacera pas la propriété correspondante dans l’instance actuelle de la FontInfo classe.

S’applique à

Voir aussi