Este artigo foi traduzido por máquina. Para visualizar o arquivo em inglês, marque a caixa de seleção Inglês. Você também pode exibir o texto Em inglês em uma janela pop-up, movendo o ponteiro do mouse sobre o texto.
Tradução
Inglês

Método Control.ControlCollection.RemoveAt (Int32)

 

Remove um controle da coleção de controles no local indexado especificado.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (em System.Windows.Forms.dll)

public void RemoveAt(
	int index
)

Parâmetros

index
Type: System.Int32

O valor de índice do Control a ser removido.

When a T:System.Windows.Forms.Control is removed from the control collection, all subsequent controls are moved up one position in the collection.

You can also remove a T:System.Windows.Forms.Control that you previously added by using the M:System.Windows.Forms.Control.ControlCollection.Remove(System.Windows.Forms.Control) or M:System.Windows.Forms.Control.ControlCollection.Clear methods.

To add new T:System.Windows.Forms.Control objects to the collection, use the M:System.Windows.Forms.Control.ControlCollection.Add(System.Windows.Forms.Control) or M:System.Windows.Forms.Control.ControlCollection.AddRange(System.Windows.Forms.Control[]) methods.

The following code example removes the first T:System.Windows.Forms.Control in the T:System.Windows.Forms.Control.ControlCollection of the derived class T:System.Windows.Forms.Panel if the count of the collection is greater than zero. The example requires that you have created a T:System.Windows.Forms.Panel, a T:System.Windows.Forms.Button, and at least one other control on a T:System.Windows.Forms.Form. The other controls are added to the T:System.Windows.Forms.Panel control, and the T:System.Windows.Forms.Panel control added to the T:System.Windows.Forms.Form. When the button is clicked, the first control contained in the panel is removed from the T:System.Windows.Forms.Control.ControlCollection.

// Remove the first control in the collection.
private void removeAtButton_Click(object sender, System.EventArgs e)
{
   if (panel1.Controls.Count > 0)
   {
      panel1.Controls.RemoveAt(0);
   }
}

.NET Framework
Disponível desde 1.1
Retornar ao início
Mostrar: