MenuItemCollection.CopyTo 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
현재 MenuItemCollection 개체의 내용을 복사합니다.
오버로드
| Name | Description |
|---|---|
| CopyTo(Array, Int32) |
대상 배열의 지정된 인덱스에서 시작하여 개체의 MenuItemCollection 모든 항목을 호환되는 1차원 Array으로 복사합니다. |
| CopyTo(MenuItem[], Int32) |
대상 배열의 지정된 인덱스에서 시작하여 개체의 MenuItemCollection 모든 항목을 MenuItem 호환되는 1차원 개체 배열로 복사합니다. |
CopyTo(Array, Int32)
대상 배열의 지정된 인덱스에서 시작하여 개체의 MenuItemCollection 모든 항목을 호환되는 1차원 Array으로 복사합니다.
public:
virtual void CopyTo(Array ^ array, int index);
public void CopyTo(Array array, int index);
abstract member CopyTo : Array * int -> unit
override this.CopyTo : Array * int -> unit
Public Sub CopyTo (array As Array, index As Integer)
매개 변수
- array
- Array
현재Array에서 복사한 항목을 받는 0부터 MenuItemCollection 시작하는 항목입니다.
- index
- Int32
복사된 콘텐츠 수신을 시작할 대상 배열의 위치입니다.
구현
예외
array 은 개체의 배열이 MenuItem 아닙니다.
설명
메서드를 CopyTo 사용하여 현재 MenuItemCollection 개체의 내용을 지정된 0부터 시작하는 System.Array개체로 복사합니다. 항목은 대상 배열의 지정된 인덱스에서 시작하여 복사됩니다. System.Array그런 다음 배열 구문을 사용하여 개체의 항목에 MenuItemCollection 액세스할 수 있습니다.
또는 이 메서드를 사용하여 컬렉션의 GetEnumerator 항목에 액세스하는 데 사용할 수 있는 열거자를 만들 수도 있습니다.
추가 정보
적용 대상
CopyTo(MenuItem[], Int32)
대상 배열의 지정된 인덱스에서 시작하여 개체의 MenuItemCollection 모든 항목을 MenuItem 호환되는 1차원 개체 배열로 복사합니다.
public:
void CopyTo(cli::array <System::Web::UI::WebControls::MenuItem ^> ^ array, int index);
public void CopyTo(System.Web.UI.WebControls.MenuItem[] array, int index);
member this.CopyTo : System.Web.UI.WebControls.MenuItem[] * int -> unit
Public Sub CopyTo (array As MenuItem(), index As Integer)
매개 변수
- array
- MenuItem[]
현재MenuItem에서 복사한 항목을 받는 개체의 MenuItemCollection 0부터 시작하는 배열입니다.
- index
- Int32
복사된 콘텐츠 수신을 시작할 대상 배열의 위치입니다.
예제
다음 코드 예제에서는 개체의 CopyTo 항목을 MenuItemCollection 개체 배열에 복사 하는 메서드를 사용 하는 MenuItem 방법을 보여 줍니다.
<%@ 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 Page_Load(Object sender, EventArgs e)
{
// Display the submenu items of the Music
// menu item.
// Retrieve the Music menu item.
MenuItem musicMenuItem = NavigationMenu.FindItem(@"Home");
// Declare an array of MenuItem objects.
MenuItem[] musicItemArray = new MenuItem[musicMenuItem.ChildItems.Count];
// Use the CopyTo method to copy the submenu items
// of the Music menu item into the array.
musicMenuItem.ChildItems.CopyTo(musicItemArray, 0);
// Display the menu items.
Message.Text = "The submenu items of the Home menu item are: <br/><br/>";
foreach (MenuItem item in musicItemArray)
{
Message.Text += item.Text + "<br />";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>MenuItemCollection CopyTo Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>MenuItemCollection CopyTo Example</h3>
<asp:menu id="NavigationMenu"
orientation="Vertical"
target="_blank"
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>
<hr/>
<asp:label id="Message"
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 Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Display the submenu items of the Music
' menu item.
' Retrieve the Music menu item.
Dim musicMenuItem As MenuItem = NavigationMenu.FindItem("Home")
' Declare an array of MenuItem objects.
Dim musicItemArray(musicMenuItem.ChildItems.Count - 1) As MenuItem
' Use the CopyTo method to copy the submenu items
' of the Music menu item into the array.
musicMenuItem.ChildItems.CopyTo(musicItemArray, 0)
' Display the menu items.
Message.Text = "The submenu items of the Home menu item are: <br/><br/>"
Dim item As MenuItem
For Each item In musicItemArray
Message.Text &= item.Text & "<br />"
Next
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>MenuItemCollection CopyTo Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>MenuItemCollection CopyTo Example</h3>
<asp:menu id="NavigationMenu"
orientation="Vertical"
target="_blank"
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>
<hr/>
<asp:label id="Message"
runat="server"/>
</form>
</body>
</html>
설명
메서드를 CopyTo 사용하여 현재 MenuItemCollection 개체의 내용을 지정된 0부터 시작하는 배열로 복사합니다. 항목은 대상 배열의 지정된 인덱스에서 시작하여 복사됩니다. 배열을 사용하면 배열 구문을 사용하여 개체의 항목에 MenuItemCollection 액세스할 수 있습니다.
또는 이 메서드를 사용하여 컬렉션의 GetEnumerator 항목에 액세스하는 데 사용할 수 있는 열거자를 만들 수도 있습니다.