FontInfo.CopyFrom メソッド
アセンブリ: System.Web (system.web.dll 内)


CopyFrom メソッドを使用して、指定した FontInfo のフォント プロパティをこのメソッドの呼び出し元である FontInfo クラスのインスタンスに複製します。
![]() |
---|
FontInfo クラスの現在のインスタンスにあるすべてのプロパティは、f パラメータの関連付けられているプロパティによって置き換えられます。 |
RegisterStyle を使用してスタイルが登録され、Style.CopyFrom を使用してコピーされる場合、個々のプロパティすべてではなく、CssClass プロパティだけがコピー先にコピーされます。したがって、FontInfo.CopyFrom を使用して、登録された Style の Font プロパティからフォント情報をコピーする場合、スタイルからフォントの個々の設定を取得することはできません。

CopyFrom メソッドを使用して、FontInfo のフォント プロパティを Label コントロールの Font プロパティに複製する方法を次の例に示します。
<%@ 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>
<%@ 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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- FontInfo.CopyFrom メソッドのページへのリンク