Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações.
Tradução
Original
Este tópico ainda não foi avaliado como - Avalie este tópico

Classe StatusBar.StatusBarPanelCollection

Representa a coleção de painéis em um StatusBar controle.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (em System.Windows.Forms.dll)
[ListBindableAttribute(false)]
public class StatusBarPanelCollection : IList, 
	ICollection, IEnumerable

The StatusBar.StatusBarPanelCollection classe armazena os painéis exibidos no StatusBar. Cada objeto na coleção é uma instância do StatusBarPanel classe que define as características de exibição e os comportamentos de um painel exibido em uma StatusBar.

Há várias maneiras de adicionar painéis à coleção. The Add método fornece a capacidade de adicionar um painel único à coleção. Para adicionar um número de painéis à coleção, crie uma matriz de StatusBarPanel objetos e atribuí-lo para o AddRange método. Se você deseja inserir um painel em um local específico dentro da coleção, você pode usar o Insert método. Para remover painéis, você pode usar ambos o Remove método ou a RemoveAt método se você souber onde o painel está localizado dentro da coleção. The Clear método permite que você remover todos os painéis da coleção em vez de usar o Remove método para remover um painel único de cada vez.

Juntamente com métodos e propriedades para adicionar e remover painéis, o StatusBar.StatusBarPanelCollection também fornece métodos para localizar painéis dentro da coleção. The Contains método permite que você determinar se um painel é um membro da coleção. Depois que souber que o painel está localizado dentro da coleção, você pode usar o IndexOf método para determinar onde o painel está localizado dentro da coleção.

O exemplo de código a seguir cria um StatusBar controle em um formulário e adiciona dois StatusBarPanel objetos. Um do StatusBarPanel, chamado panel1, exibe o texto de status de um aplicativo. O segundo StatusBarPanel, chamado panel2, exibe a data corrente e usa o ToolTipText propriedade das StatusBarPanel classe para exibir a time corrente. O exemplo usa o ShowPanels propriedade para garantir que os painéis são exibidos em vez de um painel padrão e usa o Panels propriedade para acessar o Add método para o StatusBar.StatusBarPanelCollection Para adicionar painéis para o StatusBar. O exemplo também usa o AutoSize, BorderStyle, ToolTipText, e Text Propriedades de inicializar o StatusBarPanel objetos. Este exemplo assume que o método definido no exemplo é definido e chamado a partir do construtor de um Form.

privatevoid 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 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.set_BorderStyle(StatusBarPanelBorderStyle.Sunken);

        // Initialize the text of the panel.
        panel1.set_Text("Ready...");

        // Set the AutoSize property to use all remaining space on the StatusBar.
        panel1.set_AutoSize(StatusBarPanelAutoSize.Spring);

        // Display the second panel with a raised border style.
        panel2.set_BorderStyle(StatusBarPanelBorderStyle.Raised);

        // Create ToolTip text that displays the time the application was started.
        panel2.set_ToolTipText("Started: " + System.DateTime.get_Now().ToShortTimeString());

	// Set the text of the panel to the current date.
        panel2.set_Text(System.DateTime.get_Today().ToLongDateString());

	// Set the AutoSize property to size the panel to the size of the 
        // contents.
        panel2.set_AutoSize(StatusBarPanelAutoSize.Contents);
        // Display panels in the StatusBar control.
        statusBar1.set_ShowPanels(true);
        // Add both panels to the StatusBarPanelCollection of the StatusBar.    
        statusBar1.get_Panels().Add(panel1);
        statusBar1.get_Panels().Add(panel2);
        // Add the StatusBar to the form.
        this.get_Controls().Add(statusBar1);
    } //CreateMyStatusBar


System.Object
  System.Windows.Forms.StatusBar.StatusBarPanelCollection
Quaisquer membros static (Shared no Visual Basic) públicos deste tipo são thread-safe. Não há garantia de que qualquer membro de instância seja thread-safe.

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

o.NET Framework e.NET Compact Framework não oferecem suporte a todas as versões de cada plataforma. Para obter uma lista de versões suportadas, consulte Requisitos de sistema do .NET framework.

.NET Framework

Compatível com: 3.5, 3.0, 2.0, 1.1, 1.0
Isso foi útil para você?
(1500 caracteres restantes)
Conteúdo da Comunidade Adicionar