TreeNodeCollection.AddRange(TreeNode[]) TreeNodeCollection.AddRange(TreeNode[]) TreeNodeCollection.AddRange(TreeNode[]) TreeNodeCollection.AddRange(TreeNode[]) Method

정의

이전에 만든 트리 노드의 배열을 컬렉션에 추가합니다.Adds an array of previously created tree nodes to the collection.

public:
 virtual void AddRange(cli::array <System::Windows::Forms::TreeNode ^> ^ nodes);
public virtual void AddRange (System.Windows.Forms.TreeNode[] nodes);
abstract member AddRange : System.Windows.Forms.TreeNode[] -> unit
override this.AddRange : System.Windows.Forms.TreeNode[] -> unit
Public Overridable Sub AddRange (nodes As TreeNode())

매개 변수

nodes
TreeNode[]

컬렉션에 추가할 트리 노드를 나타내는 TreeNode 개체의 배열입니다.An array of TreeNode objects representing the tree nodes to add to the collection.

예외

nodes가 다른 TreeView의 자식인 경우nodes is the child of another TreeView.

예제

다음 코드 예제에서는 복사 합니다 TreeNodeCollection 에서 TreeView 임시로 Array, 추가한 다음 다른 배열의 내용을 TreeView 를 사용 하 여를 AddRange 메서드.The following code example copies the TreeNodeCollection from a TreeView to a temporary Array, and then adds the contents of the array to another TreeView using the AddRange method. 합니다 TreeNodeCollection 원본의 TreeView 를 사용 하 여 선택을 취소는 Clear 메서드.The TreeNodeCollection from the source TreeView is cleared using the Clear method. 이 예제에서는 두 가지 TreeView 컨트롤의 컬렉션을 사용 하 여 하나 TreeNode 개체입니다.This example requires that you have two TreeView controls, one with a collection of TreeNode objects.

private:
   void MyButtonAddAllClick( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      
      // Get the 'myTreeNodeCollection' from the 'myTreeViewBase' TreeView.
      TreeNodeCollection^ myTreeNodeCollection = myTreeViewBase->Nodes;
      
      // Create an array of 'TreeNodes'.
      array<TreeNode^>^myTreeNodeArray = gcnew array<TreeNode^>(myTreeViewBase->Nodes->Count);
      
      // Copy the tree nodes to the 'myTreeNodeArray' array.
      myTreeViewBase->Nodes->CopyTo( myTreeNodeArray, 0 );
      
      // Remove all the tree nodes from the 'myTreeViewBase' TreeView.
      myTreeViewBase->Nodes->Clear();
      
      // Add the 'myTreeNodeArray' to the 'myTreeViewCustom' TreeView.
      myTreeViewCustom->Nodes->AddRange( myTreeNodeArray );
   }
private void MyButtonAddAllClick(object sender, EventArgs e)
{
   // Get the 'myTreeNodeCollection' from the 'myTreeViewBase' TreeView.
   TreeNodeCollection myTreeNodeCollection = myTreeViewBase.Nodes;
   // Create an array of 'TreeNodes'.
   TreeNode[] myTreeNodeArray = new TreeNode[myTreeViewBase.Nodes.Count];
   // Copy the tree nodes to the 'myTreeNodeArray' array.
   myTreeViewBase.Nodes.CopyTo(myTreeNodeArray,0);
   // Remove all the tree nodes from the 'myTreeViewBase' TreeView.
   myTreeViewBase.Nodes.Clear();
   // Add the 'myTreeNodeArray' to the 'myTreeViewCustom' TreeView.
   myTreeViewCustom.Nodes.AddRange(myTreeNodeArray);
}
Private Sub MyButtonAddAllClick(sender As Object, e As EventArgs)
   ' Get the 'myTreeNodeCollection' from the 'myTreeViewBase' TreeView.
   Dim myTreeNodeCollection As TreeNodeCollection = myTreeViewBase.Nodes
   ' Create an array of 'TreeNodes'.
   Dim myTreeNodeArray(myTreeViewBase.Nodes.Count-1) As TreeNode
   ' Copy the tree nodes to the 'myTreeNodeArray' array.
   myTreeViewBase.Nodes.CopyTo(myTreeNodeArray, 0)
   ' Remove all the tree nodes from the 'myTreeViewBase' TreeView.
   myTreeViewBase.Nodes.Clear()
   ' Add the 'myTreeNodeArray' to the 'myTreeViewCustom' TreeView.
      myTreeViewCustom.Nodes.AddRange(myTreeNodeArray)
End Sub

설명

합니다 TreeNode 에 포함 된 개체는 nodes 배열 컬렉션의 끝에 추가 됩니다.The TreeNode objects contained in the nodes array are appended to the end of the collection.

사용할 수는 AddRange 신속 하 게 이전에 그룹을 추가 하는 메서드를 만들 TreeNode 수동으로 각를 추가 하는 대신 컬렉션에 개체 TreeNode 사용 하 여 컬렉션을 Add 메서드.You can use the AddRange method to quickly add a group of previously created TreeNode objects to the collection instead of manually adding each TreeNode to the collection using the Add method.

제거할를 TreeNode 이전에 추가한를 사용 합니다 Remove, RemoveAt, 또는 Clear 메서드.To remove a TreeNode that you previously added, use the Remove, RemoveAt, or Clear methods.

적용 대상

추가 정보