StatusBar.StatusBarPanelCollection.Add 메서드

정의

StatusBarPanel를 컬렉션에 추가합니다.

오버로드

Add(String)

지정된 텍스트를 가지는 StatusBarPanel을 컬렉션에 추가합니다.

Add(StatusBarPanel)

StatusBarPanel를 컬렉션에 추가합니다.

Add(String)

지정된 텍스트를 가지는 StatusBarPanel을 컬렉션에 추가합니다.

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

매개 변수

text
String

추가되는 StatusBarPanel에 대한 텍스트입니다.

반환

StatusBarPanel

컬렉션에 추가된 패널을 나타내는 StatusBarPanel입니다.

설명

컨트롤에 패널을 StatusBar 추가하여 둘 이상의 정보 유형을 표시할 수 있습니다. 이 버전의 메서드는 Add 매개 변수에 지정된 텍스트를 사용하여 새 StatusBarPanel 메서드를 text 만들고 컬렉션에 추가합니다. 패널이 있는 StatusBar.StatusBarPanelCollection 순서는 패널이 컨트롤 내에 표시되는 순서를 StatusBar 나타냅니다. 패널이 컬렉션의 첫 번째 패널부터 왼쪽에서 오른쪽으로 표시됩니다. 컨트롤의 StatusBar 속성은 RightToLeft 패널이 표시되는 StatusBar순서를 변경하지 않습니다. 컬렉션의 특정 위치에 패널을 삽입하려면 메서드를 Insert 사용합니다. 단일 작업에서 컬렉션에 패널 집합을 추가하려면 이 메서드를 AddRange 사용합니다.

추가 정보

적용 대상

Add(StatusBarPanel)

StatusBarPanel를 컬렉션에 추가합니다.

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

매개 변수

value
StatusBarPanel

컬렉션에 추가할 패널을 나타내는 StatusBarPanel입니다.

반환

Int32

컬렉션에서 항목의 인덱스(0부터 시작)입니다.

예외

컬렉션에 추가되는 StatusBarPanelnull인 경우

value 매개 변수에 지정된 StatusBarPanel의 부모가 null이 아닌 경우

예제

다음 코드 예제에서는 폼에 컨트롤을 StatusBar 만들고 두 개의 StatusBarPanel 개체를 추가합니다. 중 하나는 StatusBarPanel 명명 된 개체 panel1, 애플리케이션에 대 한 상태 텍스트를 표시 합니다. 이름이 지정된 두 번째 StatusBarPanel날짜는 현재 날짜를 표시하고 클래스의 StatusBarPanel 속성을 사용하여 ToolTipText 현재 시간을 표시panel2합니다. 이 예제에서는 이 속성을 사용하여 패널이 표준 패널 대신 표시되도록 하고, 패널을 추가할 메서드에 액세스 Add 하는 데 사용하는 속성과 Panels StatusBar이 속성을 사용합니다ShowPanels.StatusBar.StatusBarPanelCollection 또한 이 예제에서는 , 및 ToolTipText속성을 사용하여 AutoSize개체를 초기화합니다StatusBarPanel.Text BorderStyle 이 예제에서는 예제에 정의된 메서드가 정의되고 해당 생성자 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

설명

컨트롤에 패널을 StatusBar 추가하여 둘 이상의 정보 유형을 표시할 수 있습니다. 이 버전의 메서드는 Add 매개 변수에 StatusBarPanel value 지정된 항목을 컬렉션에 추가합니다. 패널이 있는 StatusBar.StatusBarPanelCollection 순서는 패널이 컨트롤 내에 표시되는 순서를 StatusBar 나타냅니다. 패널이 컬렉션의 첫 번째 패널부터 왼쪽에서 오른쪽으로 표시됩니다. 컨트롤의 StatusBar 속성은 RightToLeft 패널이 표시되는 StatusBar순서를 변경하지 않습니다. 컬렉션의 특정 위치에 패널을 삽입하려면 메서드를 Insert 사용합니다. 단일 작업에서 컬렉션에 패널 집합을 추가하려면 이 메서드를 AddRange 사용합니다.

추가 정보

적용 대상