StatusBar.StatusBarPanelCollection.Add Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Voegt een StatusBarPanel aan de verzameling toe.
Overloads
| Name | Description |
|---|---|
| Add(String) |
Voegt een StatusBarPanel met de opgegeven tekst toe aan de verzameling. |
| Add(StatusBarPanel) |
Voegt een StatusBarPanel aan de verzameling toe. |
Add(String)
Voegt een StatusBarPanel met de opgegeven tekst toe aan de verzameling.
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
Parameters
- text
- String
De tekst voor de StatusBarPanel tekst die wordt toegevoegd.
Retouren
Een StatusBarPanel die het deelvenster vertegenwoordigt dat is toegevoegd aan de verzameling.
Opmerkingen
U kunt panelen toevoegen aan een StatusBar besturingselement om meer dan één type informatie weer te geven. Deze versie van de Add methode maakt een nieuwe StatusBarPanel met de tekst die is opgegeven in de text parameter en voegt deze toe aan de verzameling. De volgorde waarin panelen zich in de StatusBar.StatusBarPanelCollection volgorde bevinden, vertegenwoordigt de volgorde waarin panelen in het StatusBar besturingselement worden weergegeven. Panelen worden van links naar rechts weergegeven, beginnend met het eerste paneel in de collectie. De RightToLeft eigenschap van het StatusBar besturingselement verandert niet de volgorde waarin panelen worden weergegeven in de StatusBar. Als u een paneel op een specifieke positie in de verzameling wilt invoegen, gebruikt u de Insert methode. Als u in één bewerking een set panelen wilt toevoegen aan de verzameling, gebruikt u de AddRange methode.
Zie ook
Van toepassing op
Add(StatusBarPanel)
Voegt een StatusBarPanel aan de verzameling toe.
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
Parameters
- value
- StatusBarPanel
Een StatusBarPanel die het deelvenster vertegenwoordigt dat moet worden toegevoegd aan de verzameling.
Retouren
De op nul gebaseerde index van het item in de verzameling.
Uitzonderingen
Het StatusBarPanel toevoegen aan de verzameling was null.
Het bovenliggende element van de StatusBarPanel opgegeven in de value parameter is niet null.
Voorbeelden
In het volgende codevoorbeeld wordt een StatusBar besturingselement op een formulier gemaakt en worden twee StatusBarPanel objecten toegevoegd. Een van de objecten met de StatusBarPanel naam panel1geeft statustekst weer voor een toepassing. De tweede StatusBarPanel, benoemde panel2, geeft de huidige datum weer en gebruikt de ToolTipText eigenschap van de StatusBarPanel klasse om de huidige tijd weer te geven. In het voorbeeld wordt de ShowPanels eigenschap gebruikt om ervoor te zorgen dat de panelen worden weergegeven in plaats van een standaardpaneel, en de Panels eigenschap voor toegang tot de Add methode van de StatusBar.StatusBarPanelCollection deelvensters om de panelen toe te voegen aan de StatusBar. In het voorbeeld worden ook de AutoSizeeigenschappen , BorderStyleen TextToolTipTexteigenschappen gebruikt om de StatusBarPanel objecten te initialiseren. In dit voorbeeld wordt ervan uitgegaan dat de in het voorbeeld gedefinieerde methode wordt gedefinieerd en aangeroepen vanuit de constructor van een 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
Opmerkingen
U kunt panelen toevoegen aan een StatusBar besturingselement om meer dan één type informatie weer te geven. Met deze versie van de Add methode wordt de StatusBarPanel opgegeven in de value parameter toegevoegd aan de verzameling. De volgorde waarin panelen zich in de StatusBar.StatusBarPanelCollection volgorde bevinden, vertegenwoordigt de volgorde waarin panelen in het StatusBar besturingselement worden weergegeven. Panelen worden van links naar rechts weergegeven, beginnend met het eerste paneel in de collectie. De RightToLeft eigenschap van het StatusBar besturingselement verandert niet de volgorde waarin panelen worden weergegeven in de StatusBar. Als u een paneel op een specifieke positie in de verzameling wilt invoegen, gebruikt u de Insert methode. Als u in één bewerking een set panelen wilt toevoegen aan de verzameling, gebruikt u de AddRange methode.