Condividi tramite


TreeNodeCollection.Insert Metodo

Definizione

Inserisce un elemento nella raccolta in una posizione specificata.

Overload

Nome Descrizione
Insert(Int32, String, String, String, String)

Crea un nodo della struttura ad albero con la chiave, il testo e le immagini specificate e lo inserisce nella raccolta in corrispondenza dell'indice specificato.

Insert(Int32, String, String, Int32, Int32)

Crea un nodo della struttura ad albero con la chiave, il testo e le immagini specificate e lo inserisce nella raccolta in corrispondenza dell'indice specificato.

Insert(Int32, String, String, String)

Crea un nodo della struttura ad albero con la chiave, il testo e l'immagine specificati e lo inserisce nella raccolta in corrispondenza dell'indice specificato.

Insert(Int32, String, String)

Crea un nodo della struttura ad albero con il testo e la chiave specificati e lo inserisce nella raccolta.

Insert(Int32, TreeNode)

Inserisce un nodo della struttura ad albero esistente nella raccolta di nodi della struttura ad albero nella posizione specificata.

Insert(Int32, String)

Crea un nodo della struttura ad albero con il testo specificato e lo inserisce in corrispondenza dell'indice specificato.

Insert(Int32, String, String, Int32)

Crea un nodo della struttura ad albero con la chiave, il testo e l'immagine specificati e lo inserisce nella raccolta in corrispondenza dell'indice specificato.

Insert(Int32, String, String, String, String)

Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs

Crea un nodo della struttura ad albero con la chiave, il testo e le immagini specificate e lo inserisce nella raccolta in corrispondenza dell'indice specificato.

public:
 virtual System::Windows::Forms::TreeNode ^ Insert(int index, System::String ^ key, System::String ^ text, System::String ^ imageKey, System::String ^ selectedImageKey);
public virtual System.Windows.Forms.TreeNode Insert(int index, string key, string text, string imageKey, string selectedImageKey);
public virtual System.Windows.Forms.TreeNode Insert(int index, string? key, string? text, string? imageKey, string? selectedImageKey);
abstract member Insert : int * string * string * string * string -> System.Windows.Forms.TreeNode
override this.Insert : int * string * string * string * string -> System.Windows.Forms.TreeNode
Public Overridable Function Insert (index As Integer, key As String, text As String, imageKey As String, selectedImageKey As String) As TreeNode

Parametri

index
Int32

Posizione all'interno della raccolta in cui inserire il nodo.

key
String

Nome del nodo della struttura ad albero.

text
String

Testo da visualizzare nel nodo della struttura ad albero.

imageKey
String

Chiave dell'immagine da visualizzare nel nodo della struttura ad albero.

selectedImageKey
String

Chiave dell'immagine da visualizzare nel nodo della struttura ad albero quando si trova in uno stato selezionato.

Restituisce

Oggetto TreeNode inserito nell'insieme.

Commenti

Se la Sorted proprietà è impostata su true, il valore del index parametro viene ignorato. L'oggetto TreeNode viene inserito nella visualizzazione struttura ad albero e viene TreeView ordinato di nuovo.

È anche possibile aggiungere nuovi TreeNode oggetti all'insieme utilizzando i Add metodi o AddRange .

La Name proprietà corrisponde alla chiave di un TreeNode oggetto TreeNodeCollectionin .

Il imageKey parametro fa riferimento a un'immagine nella ImageList proprietà dell'elemento padre TreeView.

Il selectedimageKey parametro fa riferimento a un'immagine nella StateImageList proprietà dell'elemento padre TreeView.

Si applica a

Insert(Int32, String, String, Int32, Int32)

Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs

Crea un nodo della struttura ad albero con la chiave, il testo e le immagini specificate e lo inserisce nella raccolta in corrispondenza dell'indice specificato.

public:
 virtual System::Windows::Forms::TreeNode ^ Insert(int index, System::String ^ key, System::String ^ text, int imageIndex, int selectedImageIndex);
public virtual System.Windows.Forms.TreeNode Insert(int index, string key, string text, int imageIndex, int selectedImageIndex);
public virtual System.Windows.Forms.TreeNode Insert(int index, string? key, string? text, int imageIndex, int selectedImageIndex);
abstract member Insert : int * string * string * int * int -> System.Windows.Forms.TreeNode
override this.Insert : int * string * string * int * int -> System.Windows.Forms.TreeNode
Public Overridable Function Insert (index As Integer, key As String, text As String, imageIndex As Integer, selectedImageIndex As Integer) As TreeNode

Parametri

index
Int32

Posizione all'interno della raccolta in cui inserire il nodo.

key
String

Nome del nodo della struttura ad albero.

text
String

Testo da visualizzare nel nodo della struttura ad albero.

imageIndex
Int32

Indice dell'immagine da visualizzare nel nodo della struttura ad albero.

selectedImageIndex
Int32

Indice dell'immagine da visualizzare nel nodo della struttura ad albero quando si trova in uno stato selezionato.

Restituisce

Oggetto TreeNode inserito nell'insieme.

Commenti

Se la Sorted proprietà è impostata su true, il valore del index parametro viene ignorato. L'oggetto TreeNode viene inserito nella visualizzazione struttura ad albero e viene TreeView ordinato di nuovo.

È anche possibile aggiungere nuovi TreeNode oggetti all'insieme utilizzando i Add metodi o AddRange .

La Name proprietà corrisponde alla chiave di un TreeNode oggetto TreeNodeCollectionin .

Il imageIndex parametro fa riferimento a un'immagine nella ImageList proprietà dell'elemento padre TreeView.

Il selectedimageIndex parametro fa riferimento a un'immagine nella StateImageList proprietà dell'elemento padre TreeView.

Si applica a

Insert(Int32, String, String, String)

Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs

Crea un nodo della struttura ad albero con la chiave, il testo e l'immagine specificati e lo inserisce nella raccolta in corrispondenza dell'indice specificato.

public:
 virtual System::Windows::Forms::TreeNode ^ Insert(int index, System::String ^ key, System::String ^ text, System::String ^ imageKey);
public virtual System.Windows.Forms.TreeNode Insert(int index, string key, string text, string imageKey);
public virtual System.Windows.Forms.TreeNode Insert(int index, string? key, string? text, string? imageKey);
abstract member Insert : int * string * string * string -> System.Windows.Forms.TreeNode
override this.Insert : int * string * string * string -> System.Windows.Forms.TreeNode
Public Overridable Function Insert (index As Integer, key As String, text As String, imageKey As String) As TreeNode

Parametri

index
Int32

Posizione all'interno della raccolta in cui inserire il nodo.

key
String

Nome del nodo della struttura ad albero.

text
String

Testo da visualizzare nel nodo della struttura ad albero.

imageKey
String

Chiave dell'immagine da visualizzare nel nodo della struttura ad albero.

Restituisce

Oggetto TreeNode inserito nell'insieme.

Commenti

Se la Sorted proprietà è impostata su true, il valore del index parametro viene ignorato. L'oggetto TreeNode viene inserito nella visualizzazione struttura ad albero e viene TreeView ordinato di nuovo.

È anche possibile aggiungere nuovi TreeNode oggetti all'insieme utilizzando i Add metodi o AddRange .

La Name proprietà corrisponde alla chiave di un TreeNode oggetto TreeNodeCollectionin .

Il imageKey parametro fa riferimento a un'immagine nella ImageList proprietà dell'elemento padre TreeView.

Si applica a

Insert(Int32, String, String)

Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs

Crea un nodo della struttura ad albero con il testo e la chiave specificati e lo inserisce nella raccolta.

public:
 virtual System::Windows::Forms::TreeNode ^ Insert(int index, System::String ^ key, System::String ^ text);
public virtual System.Windows.Forms.TreeNode Insert(int index, string key, string text);
public virtual System.Windows.Forms.TreeNode Insert(int index, string? key, string? text);
abstract member Insert : int * string * string -> System.Windows.Forms.TreeNode
override this.Insert : int * string * string -> System.Windows.Forms.TreeNode
Public Overridable Function Insert (index As Integer, key As String, text As String) As TreeNode

Parametri

index
Int32

Posizione all'interno della raccolta in cui inserire il nodo.

key
String

Nome del nodo della struttura ad albero.

text
String

Testo da visualizzare nel nodo della struttura ad albero.

Restituisce

Oggetto TreeNode inserito nell'insieme.

Commenti

Se la Sorted proprietà è impostata su true, il valore del index parametro viene ignorato. L'oggetto TreeNode viene inserito nella visualizzazione struttura ad albero e viene TreeView ordinato di nuovo.

È anche possibile aggiungere nuovi TreeNode oggetti all'insieme utilizzando i Add metodi o AddRange .

La Name proprietà corrisponde alla chiave di un TreeNode oggetto TreeNodeCollectionin .

Si applica a

Insert(Int32, TreeNode)

Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs

Inserisce un nodo della struttura ad albero esistente nella raccolta di nodi della struttura ad albero nella posizione specificata.

public:
 virtual void Insert(int index, System::Windows::Forms::TreeNode ^ node);
public virtual void Insert(int index, System.Windows.Forms.TreeNode node);
abstract member Insert : int * System.Windows.Forms.TreeNode -> unit
override this.Insert : int * System.Windows.Forms.TreeNode -> unit
Public Overridable Sub Insert (index As Integer, node As TreeNode)

Parametri

index
Int32

Posizione indicizzata all'interno della raccolta per inserire il nodo della struttura ad albero.

node
TreeNode

Oggetto TreeNode da inserire nella raccolta.

Eccezioni

L'oggetto node è attualmente assegnato a un altro TreeViewoggetto .

Esempio

Nell'esempio di codice seguente il nodo dell'albero selezionato viene rimosso da uno TreeView e lo aggiunge a un altro se entrambe le raccolte di nodi della struttura ad albero non sono di sola lettura. Quando si fa clic su un oggetto Button , l'oggetto TreeNode rappresentato dalla TreeView.SelectedNode proprietà viene eliminato da un TreeView oggetto utilizzando il Remove metodo e aggiunto all'altro TreeView utilizzando il Insert metodo . In questo esempio è necessario disporre di un oggetto Form che contiene due TreeView controlli e un oggetto Button. I TreeView controlli devono essere denominati treeView1 e treeView2.

void button1_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
   // If neither TreeNodeCollection is read-only, move the
   // selected node from treeView1 to treeView2.
   if (  !treeView1->Nodes->IsReadOnly &&  !treeView2->Nodes->IsReadOnly )
   {
      if ( treeView1->SelectedNode != nullptr )
      {
         TreeNode^ tn = treeView1->SelectedNode;
         treeView1->Nodes->Remove( tn );
         treeView2->Nodes->Insert( treeView2->Nodes->Count, tn );
      }
   }
}
private void button1_Click(object sender, EventArgs e)
{
   // If neither TreeNodeCollection is read-only, move the 
   // selected node from treeView1 to treeView2.
   if(!treeView1.Nodes.IsReadOnly && !treeView2.Nodes.IsReadOnly)
   {
      if(treeView1.SelectedNode != null)
      {
         TreeNode tn = treeView1.SelectedNode;
         treeView1.Nodes.Remove(tn);
         treeView2.Nodes.Insert(treeView2.Nodes.Count, tn);
      }
   }
}
Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click
   ' If neither TreeNodeCollection is read-only, move the 
   ' selected node from treeView1 to treeView2. 
   If Not treeView1.Nodes.IsReadOnly And Not treeView2.Nodes.IsReadOnly Then
      If (treeView1.SelectedNode IsNot Nothing) Then
         Dim tn As TreeNode = treeView1.SelectedNode
         treeView1.Nodes.Remove(tn)
         treeView2.Nodes.Insert(treeView2.Nodes.Count, tn)
      End If
   End If
End Sub

Commenti

Se la TreeView.Sorted proprietà è impostata su true, il valore del index parametro viene ignorato. L'oggetto TreeNode viene inserito nella visualizzazione albero e nel TreeView resort.

È anche possibile aggiungere nuovi TreeNode oggetti all'insieme utilizzando i Add metodi o AddRange .

Per rimuovere un oggetto TreeNode aggiunto in precedenza, usare i Removemetodi , RemoveAto Clear .

Annotazioni

Un TreeNode oggetto può essere assegnato a un TreeView solo controllo alla volta. Per aggiungere il nodo della struttura ad albero a un nuovo controllo di visualizzazione albero, è necessario rimuoverlo dall'altra visualizzazione albero o clonarlo.

Si applica a

Insert(Int32, String)

Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs

Crea un nodo della struttura ad albero con il testo specificato e lo inserisce in corrispondenza dell'indice specificato.

public:
 virtual System::Windows::Forms::TreeNode ^ Insert(int index, System::String ^ text);
public virtual System.Windows.Forms.TreeNode Insert(int index, string text);
public virtual System.Windows.Forms.TreeNode Insert(int index, string? text);
abstract member Insert : int * string -> System.Windows.Forms.TreeNode
override this.Insert : int * string -> System.Windows.Forms.TreeNode
Public Overridable Function Insert (index As Integer, text As String) As TreeNode

Parametri

index
Int32

Posizione all'interno della raccolta in cui inserire il nodo.

text
String

Testo da visualizzare nel nodo della struttura ad albero.

Restituisce

Oggetto TreeNode inserito nell'insieme.

Commenti

Se la Sorted proprietà è impostata su true, il valore del index parametro viene ignorato. L'oggetto TreeNode viene inserito nella visualizzazione struttura ad albero e viene TreeView ordinato di nuovo.

È anche possibile aggiungere nuovi TreeNode oggetti all'insieme utilizzando i Add metodi o AddRange .

Si applica a

Insert(Int32, String, String, Int32)

Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs
Origine:
TreeNodeCollection.cs

Crea un nodo della struttura ad albero con la chiave, il testo e l'immagine specificati e lo inserisce nella raccolta in corrispondenza dell'indice specificato.

public:
 virtual System::Windows::Forms::TreeNode ^ Insert(int index, System::String ^ key, System::String ^ text, int imageIndex);
public virtual System.Windows.Forms.TreeNode Insert(int index, string key, string text, int imageIndex);
public virtual System.Windows.Forms.TreeNode Insert(int index, string? key, string? text, int imageIndex);
abstract member Insert : int * string * string * int -> System.Windows.Forms.TreeNode
override this.Insert : int * string * string * int -> System.Windows.Forms.TreeNode
Public Overridable Function Insert (index As Integer, key As String, text As String, imageIndex As Integer) As TreeNode

Parametri

index
Int32

Posizione all'interno della raccolta in cui inserire il nodo.

key
String

Nome del nodo della struttura ad albero.

text
String

Testo da visualizzare nel nodo della struttura ad albero.

imageIndex
Int32

Indice dell'immagine da visualizzare nel nodo della struttura ad albero.

Restituisce

Oggetto TreeNode inserito nell'insieme.

Commenti

Se la Sorted proprietà è impostata su true, il valore del index parametro viene ignorato. L'oggetto TreeNode viene inserito nella visualizzazione struttura ad albero e viene TreeView ordinato di nuovo.

È anche possibile aggiungere nuovi TreeNode oggetti all'insieme utilizzando i Add metodi o AddRange .

La Name proprietà corrisponde alla chiave di un TreeNode oggetto TreeNodeCollectionin .

Il imageIndex parametro fa riferimento a un'immagine nella ImageList proprietà dell'elemento padre TreeView.

Si applica a