MenuItemStyle.CopyFrom(Style) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
Style 클래스의 현재 인스턴스에 지정된 MenuItemStyle 개체의 스타일 속성을 복사합니다.
public:
override void CopyFrom(System::Web::UI::WebControls::Style ^ s);
public override void CopyFrom (System.Web.UI.WebControls.Style s);
override this.CopyFrom : System.Web.UI.WebControls.Style -> unit
Public Overrides Sub CopyFrom (s As Style)
매개 변수
예제
다음 코드 예제를 사용 하는 방법에 설명 합니다 CopyFrom 다른의 스타일 설정을 복사 하는 메서드 MenuItemStyle 개체입니다.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>MenuItemStyle CopyFrom Example</title>
</head>
<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="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>MenuItemStyle CopyFrom Example</title>
</head>
<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>
설명
사용 합니다 CopyFrom 지정 된 스타일 속성을 복제 하는 방법 Style 개체는 MenuItemStyle 이 메서드를 호출 하는 개체입니다.
주의
현재 인스턴스의 모든 속성을 MenuItemStyle 해당 속성에 지정 된 클래스 바뀝니다 Style 개체입니다.
설정 된 값을 바꾸지 않고 스타일 속성을 복사 하려면 사용 된 MergeWith 메서드.