ToolBar.ToolBarButtonCollection.Clear Método
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Remove todos os botões da coleção de botões da barra de ferramentas.
public:
virtual void Clear();
public void Clear();
abstract member Clear : unit -> unit
override this.Clear : unit -> unit
Public Sub Clear ()
Implementações
Exemplos
O exemplo de código a seguir exibe o CountButtons antes e depois do Clear método ser chamado. Esse código requer que um ToolBar com pelo menos um ToolBarButton tenha sido criado.
public:
void ClearMyToolBar()
{
int btns;
// Get the count before the Clear method is called.
btns = toolBar1->Buttons->Count;
toolBar1->Buttons->Clear();
MessageBox::Show( "Count Before Clear: " + btns.ToString() +
"\nCount After Clear: " + toolBar1->Buttons->Count.ToString() );
}
public void ClearMyToolBar()
{
int btns;
// Get the count before the Clear method is called.
btns = toolBar1.Buttons.Count;
toolBar1.Buttons.Clear();
MessageBox.Show("Count Before Clear: " + btns.ToString() +
"\nCount After Clear: " + toolBar1.Buttons.Count.ToString());
}
Public Sub ClearMyToolBar()
Dim btns As Integer
' Get the count before the Clear method is called.
btns = toolBar1.Buttons.Count
toolBar1.Buttons.Clear()
MessageBox.Show("Count Before Clear: " + btns.ToString() & _
Microsoft.VisualBasic.ControlChars.Cr & "Count After Clear: " & _
toolBar1.Buttons.Count.ToString())
End Sub
Comentários
O Clear método itera pela coleção e remove todos os botões da barra de ferramentas atribuídos ao ToolBar.ToolBarButtonCollection.
Para remover um botão de barra de ferramentas individual da coleção, use os métodos ou Remove os RemoveAt métodos.
Para adicionar novos ToolBarButton objetos à coleção, use os Addmétodos ou AddRange . Insert