StatusBar.StatusBarPanelCollection.Add Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Acrescenta um a StatusBarPanel à coleção.
Sobrecargas
| Name | Descrição |
|---|---|
| Add(String) |
Adiciona a StatusBarPanel com o texto especificado à coleção. |
| Add(StatusBarPanel) |
Acrescenta um a StatusBarPanel à coleção. |
Add(String)
Adiciona a StatusBarPanel com o texto especificado à coleção.
public:
virtual System::Windows::Forms::StatusBarPanel ^ Add(System::String ^ text);
public virtual System.Windows.Forms.StatusBarPanel Add(string text);
abstract member Add : string -> System.Windows.Forms.StatusBarPanel
override this.Add : string -> System.Windows.Forms.StatusBarPanel
Public Overridable Function Add (text As String) As StatusBarPanel
Parâmetros
- text
- String
O texto para isso StatusBarPanel está a ser adicionado.
Devoluções
A StatusBarPanel que representa o painel que foi adicionado à coleção.
Observações
Pode adicionar painéis a um StatusBar controlo para mostrar mais do que um tipo de informação. Esta versão do Add método cria um novo StatusBarPanel com o texto especificado no text parâmetro e adiciona-o à coleção. A ordem em que os painéis estão localizados representa StatusBar.StatusBarPanelCollection a ordem em que os painéis são exibidos dentro do StatusBar controlo. Os painéis são exibidos da esquerda para a direita, começando pelo primeiro painel da coleção. A RightToLeft propriedade do StatusBar controlo não altera a ordem em que os painéis são exibidos no StatusBar. Para inserir um painel numa posição específica da coleção, utilize o Insert método. Para adicionar um conjunto de painéis à coleção numa única operação, use o AddRange método.
Ver também
Aplica-se a
Add(StatusBarPanel)
Acrescenta um a StatusBarPanel à coleção.
public:
virtual int Add(System::Windows::Forms::StatusBarPanel ^ value);
public virtual int Add(System.Windows.Forms.StatusBarPanel value);
abstract member Add : System.Windows.Forms.StatusBarPanel -> int
override this.Add : System.Windows.Forms.StatusBarPanel -> int
Public Overridable Function Add (value As StatusBarPanel) As Integer
Parâmetros
- value
- StatusBarPanel
A StatusBarPanel que representa o painel a adicionar à coleção.
Devoluções
O índice base zero do item na coleção.
Exceções
O StatusBarPanel ser adicionado à coleção foi null.
O pai do StatusBarPanel especificado no value parâmetro não nullé .
Exemplos
O seguinte exemplo de código cria um StatusBar controlo num formulário e adiciona dois StatusBarPanel objetos. Um dos StatusBarPanel objetos, chamado panel1, apresenta texto de estado para uma aplicação. A segunda StatusBarPanel, chamada panel2, mostra a data atual e usa a ToolTipText propriedade da StatusBarPanel classe para mostrar a hora atual. O exemplo usa a ShowPanels propriedade para garantir que os painéis são exibidos em vez de um painel padrão, e usa e a Panels propriedade para aceder ao Add método de adicionar StatusBar.StatusBarPanelCollection os painéis ao StatusBar. O exemplo também utiliza as AutoSizepropriedades , BorderStyle, ToolTipText, e Text para inicializar os StatusBarPanel objetos. Este exemplo assume que o método definido no exemplo é definido e chamado do construtor de um Form.
private:
void CreateMyStatusBar()
{
// Create a StatusBar control.
StatusBar^ statusBar1 = gcnew StatusBar;
// Create two StatusBarPanel objects to display in the StatusBar.
StatusBarPanel^ panel1 = gcnew StatusBarPanel;
StatusBarPanel^ panel2 = gcnew StatusBarPanel;
// Display the first panel with a sunken border style.
panel1->BorderStyle = StatusBarPanelBorderStyle::Sunken;
// Initialize the text of the panel.
panel1->Text = "Ready...";
// Set the AutoSize property to use all remaining space on the StatusBar.
panel1->AutoSize = StatusBarPanelAutoSize::Spring;
// Display the second panel with a raised border style.
panel2->BorderStyle = StatusBarPanelBorderStyle::Raised;
// Create ToolTip text that displays the time the application
// was started.
panel2->ToolTipText = System::DateTime::Now.ToShortTimeString();
// Set the text of the panel to the current date.
panel2->Text = "Started: " + System::DateTime::Today.ToLongDateString();
// Set the AutoSize property to size the panel to the size of the contents.
panel2->AutoSize = StatusBarPanelAutoSize::Contents;
// Display panels in the StatusBar control.
statusBar1->ShowPanels = true;
// Add both panels to the StatusBarPanelCollection of the StatusBar.
statusBar1->Panels->Add( panel1 );
statusBar1->Panels->Add( panel2 );
// Add the StatusBar to the form.
this->Controls->Add( statusBar1 );
}
private void CreateMyStatusBar()
{
// Create a StatusBar control.
StatusBar statusBar1 = new StatusBar();
// Create two StatusBarPanel objects to display in the StatusBar.
StatusBarPanel panel1 = new StatusBarPanel();
StatusBarPanel panel2 = new StatusBarPanel();
// Display the first panel with a sunken border style.
panel1.BorderStyle = StatusBarPanelBorderStyle.Sunken;
// Initialize the text of the panel.
panel1.Text = "Ready...";
// Set the AutoSize property to use all remaining space on the StatusBar.
panel1.AutoSize = StatusBarPanelAutoSize.Spring;
// Display the second panel with a raised border style.
panel2.BorderStyle = StatusBarPanelBorderStyle.Raised;
// Create ToolTip text that displays time the application was started.
panel2.ToolTipText = "Started: " + System.DateTime.Now.ToShortTimeString();
// Set the text of the panel to the current date.
panel2.Text = System.DateTime.Today.ToLongDateString();
// Set the AutoSize property to size the panel to the size of the contents.
panel2.AutoSize = StatusBarPanelAutoSize.Contents;
// Display panels in the StatusBar control.
statusBar1.ShowPanels = true;
// Add both panels to the StatusBarPanelCollection of the StatusBar.
statusBar1.Panels.Add(panel1);
statusBar1.Panels.Add(panel2);
// Add the StatusBar to the form.
this.Controls.Add(statusBar1);
}
Private Sub CreateMyStatusBar()
' Create a StatusBar control.
Dim statusBar1 As New StatusBar()
' Create two StatusBarPanel objects to display in the StatusBar.
Dim panel1 As New StatusBarPanel()
Dim panel2 As New StatusBarPanel()
' Display the first panel with a sunken border style.
panel1.BorderStyle = StatusBarPanelBorderStyle.Sunken
' Initialize the text of the panel.
panel1.Text = "Ready..."
' Set the AutoSize property to use all remaining space on the StatusBar.
panel1.AutoSize = StatusBarPanelAutoSize.Spring
' Display the second panel with a raised border style.
panel2.BorderStyle = StatusBarPanelBorderStyle.Raised
' Create ToolTip text that displays the time the application was started.
panel2.ToolTipText = "Started: " & System.DateTime.Now.ToShortTimeString()
' Set the text of the panel to the current date.
panel2.Text = System.DateTime.Today.ToLongDateString()
' Set the AutoSize property to size the panel to the size of the contents.
panel2.AutoSize = StatusBarPanelAutoSize.Contents
' Display panels in the StatusBar control.
statusBar1.ShowPanels = True
' Add both panels to the StatusBarPanelCollection of the StatusBar.
statusBar1.Panels.Add(panel1)
statusBar1.Panels.Add(panel2)
' Add the StatusBar to the form.
Me.Controls.Add(statusBar1)
End Sub
Observações
Pode adicionar painéis a um StatusBar controlo para mostrar mais do que um tipo de informação. Esta versão do Add método adiciona o StatusBarPanel especificado no value parâmetro à coleção. A ordem em que os painéis estão localizados representa StatusBar.StatusBarPanelCollection a ordem em que os painéis são exibidos dentro do StatusBar controlo. Os painéis são exibidos da esquerda para a direita, começando pelo primeiro painel da coleção. A RightToLeft propriedade do StatusBar controlo não altera a ordem em que os painéis são exibidos no StatusBar. Para inserir um painel numa posição específica da coleção, utilize o Insert método. Para adicionar um conjunto de painéis à coleção numa única operação, use o AddRange método.