TreeNodeBindingCollection.CopyTo(TreeNodeBinding[], Int32) 메서드

정의

대상 배열의 지정한 인덱스부터 시작하여 TreeNodeBindingCollection 개체의 모든 항목을 TreeNodeBinding 개체의 호환되는 1차원 배열에 복사합니다.

public:
 void CopyTo(cli::array <System::Web::UI::WebControls::TreeNodeBinding ^> ^ bindingArray, int index);
public void CopyTo (System.Web.UI.WebControls.TreeNodeBinding[] bindingArray, int index);
override this.CopyTo : System.Web.UI.WebControls.TreeNodeBinding[] * int -> unit
Public Sub CopyTo (bindingArray As TreeNodeBinding(), index As Integer)

매개 변수

bindingArray
TreeNodeBinding[]

TreeNodeBinding에서 복사한 항목을 받는 TreeNodeBindingCollection 개체의 배열(0부터 시작)입니다.

index
Int32

복사된 내용을 받기 시작할 bindingArray의 위치입니다.

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 CopyTo 의 내용을 복사 하는 메서드는 DataBindings 컬렉션을 배열에 합니다.


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

    // Create an array of TreeNodeBinding objects and then use the
    // CopyTo method to copy the contents of the DataBindings collection
    // to the array.
    TreeNodeBinding[] bindings = new TreeNodeBinding[BookTreeView.DataBindings.Count];
    BookTreeView.DataBindings.CopyTo(bindings, 0);

    // Iterate through the array and display the value of the text field
    // property of each TreeNodeBinding object.
    MessageLabel.Text = "The field names for each node level are: <br/>";

    foreach (TreeNodeBinding binding in bindings)
    {

      MessageLabel.Text += binding.TextField + "<br/>";

    }

  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeNodeBindingCollection CopyTo Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeNodeBindingCollection CopyTo Example</h3>
    
      <asp:TreeView id="BookTreeView" 
         DataSourceID="BookXmlDataSource"
         runat="server">
         
        <DataBindings>
          <asp:TreeNodeBinding DataMember="Book" 
            TextField="Title"/>
          <asp:TreeNodeBinding DataMember="Chapter" 
            TextField="Heading"/>
          <asp:TreeNodeBinding DataMember="Section" 
            TextField="Subject"/>
        </DataBindings>
         
      </asp:TreeView>
      
      <asp:XmlDataSource id="BookXmlDataSource"  
         DataFile="Book.xml"
         runat="server">
      </asp:XmlDataSource>
    
      <br/>
    
      <asp:Label id="MessageLabel" 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)

    ' Create an array of TreeNodeBinding objects and then use the
    ' CopyTo method to copy the contents of the DataBindings collection
    ' to the array.
    Dim bindings(BookTreeView.DataBindings.Count - 1) As TreeNodeBinding
    BookTreeView.DataBindings.CopyTo(bindings, 0)

    ' Iterate through the array and display the value of the text field
    ' property of each TreeNodeBinding object.
    MessageLabel.Text = "The field names for each node level are: <br/>"

    
    Dim binding As TreeNodeBinding
    For Each binding In bindings

      MessageLabel.Text &= binding.TextField & "<br/>"

    Next

  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeNodeBindingCollection CopyTo Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeNodeBindingCollection CopyTo Example</h3>
    
      <asp:TreeView id="BookTreeView" 
         DataSourceID="BookXmlDataSource"
         runat="server">
         
        <DataBindings>
          <asp:TreeNodeBinding DataMember="Book" 
            TextField="Title"/>
          <asp:TreeNodeBinding DataMember="Chapter" 
            TextField="Heading"/>
          <asp:TreeNodeBinding DataMember="Section" 
            TextField="Subject"/>
        </DataBindings>
         
      </asp:TreeView>
      
      <asp:XmlDataSource id="BookXmlDataSource"  
         DataFile="Book.xml"
         runat="server">
      </asp:XmlDataSource>
    
      <br/>
    
      <asp:Label id="MessageLabel" runat="server"/>
    
    </form>
  </body>
</html>

설명

사용 합니다 CopyTo 의 내용을 복사 하는 메서드를 TreeNodeBindingCollection 개체를 bindingArray입니다. 항목부터 복사 됩니다 index합니다. 그런 다음 컬렉션에 있는 항목에 액세스 하려면 배열을 사용할 수 있습니다.

사용할 수 있습니다는 GetEnumerator 컬렉션의 항목에 액세스할 수 있는 열거자를 만드는 방법.

적용 대상

추가 정보