StatusBarPanel.AutoSize 속성

정의

상태 표시줄 패널의 크기를 자동으로 조정할지를 나타내는 값을 가져오거나 설정합니다.

public:
 property System::Windows::Forms::StatusBarPanelAutoSize AutoSize { System::Windows::Forms::StatusBarPanelAutoSize get(); void set(System::Windows::Forms::StatusBarPanelAutoSize value); };
public System.Windows.Forms.StatusBarPanelAutoSize AutoSize { get; set; }
member this.AutoSize : System.Windows.Forms.StatusBarPanelAutoSize with get, set
Public Property AutoSize As StatusBarPanelAutoSize

속성 값

StatusBarPanelAutoSize

StatusBarPanelAutoSize 값 중 하나입니다. 기본값은 None입니다.

예외

속성에 할당된 값이 StatusBarPanelAutoSize 열거형의 멤버가 아닌 경우

예제

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

설명

StatusBarPanel 개체가 값으로 Contents 설정된 패널보다 우선적으로 설정됩니다 Spring . 예를 들어 StatusBarPanel 속성이 설정된 Spring 속성이 있는 경우 해당 공간이 필요한 경우 StatusBarPanel 해당 속성이 AutoSize 있는 값이 줄어드는 경우가 Contents AutoSize 있습니다.

둘 이상의 패널이 StatusBarPanel 포함된 컨트롤에 StatusBar 콘텐츠가 제대로 표시되는지 확인하는 데 사용할 AutoSize 수 있습니다. 예를 들어 텍스트가 포함된 패널이 표시되는 텍스트 양()Contents에 맞게 자동으로 조정되도록 할 수 있지만 소유자가 그린 진행률 표시줄을 표시하는 다른 패널은 StatusBar 고정 크기(None)여야 합니다.

적용 대상

추가 정보