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


CopyFrom メソッドを使用して、指定された Style オブジェクトのスタイル プロパティを、このメソッドを呼び出す MenuItemStyle オブジェクトにコピーします。
![]() |
---|
MenuItemStyle クラスの現在のインスタンスにあるすべてのプロパティは、指定された Style オブジェクトの対応するプロパティによって置き換えられます。 |

CopyFrom メソッドを使用して、別の MenuItemStyle オブジェクトのスタイル設定をコピーする方法のコード例を次に示します。
<%@ Page Language="VB" %> <script runat="server"> Sub SubmitButton_Click(ByVal sender As Object, ByVal e As EventArgs) ' Use the CopyFrom method to copy the ' StaticMenuItemStyle property settings from ' the source Menu control to the target ' Menu control. Dim sourceMenuStyle As MenuItemStyle = SourceMenu.StaticMenuItemStyle TargetMenu.StaticMenuItemStyle.CopyFrom(sourceMenuStyle) End Sub Sub ResetButton_Click(ByVal sender As Object, ByVal e As EventArgs) ' Use the Reset method to return the ' StaticMenuItemStyle property of the ' target Menu control to its default ' values. TargetMenu.StaticMenuItemStyle.Reset() End Sub </script> <html> <body> <form id="Form1" runat="server"> <h3>MenuItemStyle CopyFrom Example</h3> <table cellpadding="20" border="1"> <tr> <th> Source StaticMenuItemStyle </th> <th> Target StaticMenuItemStyle </th> </tr> <tr> <td> <asp:menu id="SourceMenu" staticdisplaylevels="2" staticsubmenuindent="10" orientation="Vertical" runat="server"> <staticmenuitemstyle backcolor="LightSteelBlue" horizontalpadding="5" verticalpadding="2" font-names="Arial" forecolor="Black"/> <items> <asp:menuitem text="Home" tooltip="Home"> <asp:menuitem text="Music" tooltip="Music"> <asp:menuitem text="Classical" tooltip="Classical"/> <asp:menuitem text="Rock" tooltip="Rock"/> <asp:menuitem text="Jazz" tooltip="Jazz"/> </asp:menuitem> <asp:menuitem text="Movies" tooltip="Movies"> <asp:menuitem text="Action" tooltip="Action"/> <asp:menuitem text="Drama" tooltip="Drama"/> <asp:menuitem text="Musical" tooltip="Musical"/> </asp:menuitem> </asp:menuitem> </items> </asp:menu> </td> <td> <asp:menu id="TargetMenu" staticdisplaylevels="2" staticsubmenuindent="10" orientation="Vertical" runat="server"> <items> <asp:menuitem text="Home" tooltip="Home"> <asp:menuitem text="Music" tooltip="Music"> <asp:menuitem text="Classical" tooltip="Classical"/> <asp:menuitem text="Rock" tooltip="Rock"/> <asp:menuitem text="Jazz" tooltip="Jazz"/> </asp:menuitem> <asp:menuitem text="Movies" tooltip="Movies"> <asp:menuitem text="Action" tooltip="Action"/> <asp:menuitem text="Drama" tooltip="Drama"/> <asp:menuitem text="Musical" tooltip="Musical"/> </asp:menuitem> </asp:menuitem> </items> </asp:menu> </td> </tr> </table> <asp:button id="SubmitButton" text="Copy Static Menu Item Style" onclick="SubmitButton_Click" runat="server"/> <asp:button id="ResetButton" text="Reset Style" onclick="ResetButton_Click" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> void SubmitButton_Click(Object sender, EventArgs e) { // Use the CopyFrom method to copy the // StaticMenuItemStyle property settings from // the source Menu control to the target // Menu control. MenuItemStyle sourceMenuStyle = SourceMenu.StaticMenuItemStyle; TargetMenu.StaticMenuItemStyle.CopyFrom(sourceMenuStyle); } void ResetButton_Click(Object sender, EventArgs e) { // Use the Reset method to return the // StaticMenuItemStyle property of the // target Menu control to its default // values. TargetMenu.StaticMenuItemStyle.Reset(); } </script> <html> <body> <form runat="server"> <h3>MenuItemStyle CopyFrom Example</h3> <table cellpadding="20" border="1"> <tr> <th> Source StaticMenuItemStyle </th> <th> Target StaticMenuItemStyle </th> </tr> <tr> <td> <asp:menu id="SourceMenu" staticdisplaylevels="2" staticsubmenuindent="10" orientation="Vertical" runat="server"> <staticmenuitemstyle backcolor="LightSteelBlue" horizontalpadding="5" verticalpadding="2" font-names="Arial" forecolor="Black"/> <items> <asp:menuitem text="Home" tooltip="Home"> <asp:menuitem text="Music" tooltip="Music"> <asp:menuitem text="Classical" tooltip="Classical"/> <asp:menuitem text="Rock" tooltip="Rock"/> <asp:menuitem text="Jazz" tooltip="Jazz"/> </asp:menuitem> <asp:menuitem text="Movies" tooltip="Movies"> <asp:menuitem text="Action" tooltip="Action"/> <asp:menuitem text="Drama" tooltip="Drama"/> <asp:menuitem text="Musical" tooltip="Musical"/> </asp:menuitem> </asp:menuitem> </items> </asp:menu> </td> <td> <asp:menu id="TargetMenu" staticdisplaylevels="2" staticsubmenuindent="10" orientation="Vertical" runat="server"> <items> <asp:menuitem text="Home" tooltip="Home"> <asp:menuitem text="Music" tooltip="Music"> <asp:menuitem text="Classical" tooltip="Classical"/> <asp:menuitem text="Rock" tooltip="Rock"/> <asp:menuitem text="Jazz" tooltip="Jazz"/> </asp:menuitem> <asp:menuitem text="Movies" tooltip="Movies"> <asp:menuitem text="Action" tooltip="Action"/> <asp:menuitem text="Drama" tooltip="Drama"/> <asp:menuitem text="Musical" tooltip="Musical"/> </asp:menuitem> </asp:menuitem> </items> </asp:menu> </td> </tr> </table> <asp:button id="SubmitButton" text="Copy Static Menu Item Style" onclick="SubmitButton_Click" runat="server"/> <asp:button id="ResetButton" text="Reset Style" onclick="ResetButton_Click" 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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からMenuItemStyle.CopyFrom メソッドを検索する場合は、下記のリンクをクリックしてください。

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