StatusBar.StatusBarPanelCollection.Add Metode

Definisi

StatusBarPanel Menambahkan ke koleksi.

Overload

Nama Deskripsi
Add(String)

StatusBarPanel Menambahkan dengan teks yang ditentukan ke koleksi.

Add(StatusBarPanel)

StatusBarPanel Menambahkan ke koleksi.

Add(String)

Sumber:
StatusBar.StatusBarPanelCollection.cs
Sumber:
StatusBar.StatusBarPanelCollection.cs

StatusBarPanel Menambahkan dengan teks yang ditentukan ke koleksi.

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

Parameter

text
String

Teks untuk StatusBarPanel yang sedang ditambahkan.

Mengembalikan

StatusBarPanel Yang mewakili panel yang ditambahkan ke koleksi.

Keterangan

Anda dapat menambahkan panel ke StatusBar kontrol untuk menampilkan lebih dari satu jenis informasi. Versi Add metode ini membuat yang baru StatusBarPanel dengan teks yang ditentukan dalam text parameter dan menambahkannya ke koleksi. Urutan di mana panel terletak di StatusBar.StatusBarPanelCollection mewakili urutan panel ditampilkan dalam StatusBar kontrol. Panel ditampilkan dari kiri ke kanan dimulai dengan panel pertama dalam koleksi. Properti RightToLeftStatusBar kontrol tidak mengubah urutan panel ditampilkan di StatusBar. Untuk menyisipkan panel pada posisi tertentu dalam koleksi, gunakan Insert metode . Untuk menambahkan sekumpulan panel ke koleksi dalam satu operasi, gunakan metode .AddRange

Lihat juga

Berlaku untuk

Add(StatusBarPanel)

Sumber:
StatusBar.StatusBarPanelCollection.cs
Sumber:
StatusBar.StatusBarPanelCollection.cs

StatusBarPanel Menambahkan ke koleksi.

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

Parameter

value
StatusBarPanel

StatusBarPanel Yang mewakili panel untuk ditambahkan ke koleksi.

Mengembalikan

Indeks berbasis nol item dalam koleksi.

Pengecualian

Yang StatusBarPanel ditambahkan ke koleksi adalah null.

Induk dari yang StatusBarPanel ditentukan dalam value parameter bukan null.

Contoh

Contoh kode berikut membuat StatusBar kontrol pada formulir dan menambahkan dua StatusBarPanel objek. Salah StatusBarPanel satu objek, bernama panel1, menampilkan teks status untuk aplikasi. Yang kedua StatusBarPanel, bernama panel2, menampilkan tanggal saat ini dan menggunakan ToolTipText properti StatusBarPanel kelas untuk menampilkan waktu saat ini. Contoh menggunakan ShowPanels properti untuk memastikan bahwa panel ditampilkan alih-alih panel standar, dan menggunakan dan Panels properti untuk mengakses Add metode StatusBar.StatusBarPanelCollection untuk menambahkan panel ke StatusBar. Contohnya juga menggunakan AutoSizeproperti , BorderStyle, ToolTipText, dan Text untuk menginisialisasi StatusBarPanel objek. Contoh ini mengasumsikan bahwa metode yang ditentukan dalam contoh ditentukan dan dipanggil dari konstruktor .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

Keterangan

Anda dapat menambahkan panel ke StatusBar kontrol untuk menampilkan lebih dari satu jenis informasi. Versi Add metode ini menambahkan StatusBarPanel yang ditentukan dalam value parameter ke koleksi. Urutan di mana panel terletak di StatusBar.StatusBarPanelCollection mewakili urutan panel ditampilkan dalam StatusBar kontrol. Panel ditampilkan dari kiri ke kanan dimulai dengan panel pertama dalam koleksi. Properti RightToLeftStatusBar kontrol tidak mengubah urutan panel ditampilkan di StatusBar. Untuk menyisipkan panel pada posisi tertentu dalam koleksi, gunakan Insert metode . Untuk menambahkan sekumpulan panel ke koleksi dalam satu operasi, gunakan metode .AddRange

Lihat juga

Berlaku untuk