다음을 통해 공유


StatusBarPanel 클래스

StatusBar 컨트롤의 패널을 나타냅니다. StatusStrip 컨트롤은 이전 버전의 StatusBar 컨트롤을 대체하고 여기에 다른 기능을 추가하여 새로 도입된 컨트롤이지만 이전 버전과의 호환성 및 이후 사용 가능성을 고려하여 StatusBar을 계속 유지하도록 선택할 수 있습니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Class StatusBarPanel
    Inherits Component
    Implements ISupportInitialize
‘사용 방법
Dim instance As StatusBarPanel
public class StatusBarPanel : Component, ISupportInitialize
public ref class StatusBarPanel : public Component, ISupportInitialize
public class StatusBarPanel extends Component implements ISupportInitialize
public class StatusBarPanel extends Component implements ISupportInitialize

설명

StatusBarPanelStatusBar 컨트롤의 StatusBar.StatusBarPanelCollection에 있는 각 패널을 나타냅니다. StatusBarPanel은 응용 프로그램의 상태를 반영하는 데 사용될 수 있는 텍스트 및/또는 아이콘을 포함할 수 있습니다. 개별 StatusBarPanel을 가져오거나, 추가하거나, 제거하려면 StatusBar 컨트롤의 StatusBar.Panels 속성을 통해 액세스할 수 있는 StatusBar.StatusBarPanelCollection을 사용합니다.

StatusBarPanel에는 StatusBar 컨트롤 내에서 패널의 표시 동작을 수정할 수 있도록 하는 속성이 있습니다. Icon 속성을 사용하면 패널에 아이콘을 표시할 수 있습니다. 이 속성을 사용하면 응용 프로그램에서 상태를 그래픽으로 표시할 수 있습니다. Alignment 속성을 사용하면 텍스트 및/또는 아이콘이 패널 내에서 정렬되는 방법을 지정할 수 있습니다. 패널의 텍스트 크기에 맞게 패널 크기를 적절히 조정하려면 AutoSize 속성을 사용하여 패널의 텍스트 크기에 맞게 패널의 크기를 자동으로 조정하거나 StatusBar 컨트롤의 나머지 공간을 채웁니다. MinWidth 속성을 사용하면 패널에 표시할 데이터보다 패널이 작아지지 않도록 패널의 최소 너비를 지정할 수 있습니다.

StatusBar 컨트롤은 일반적으로 응용 프로그램에 대한 도움말 정보나 상태 정보를 표시하는 데 사용됩니다. 종종 패널에 표시되는 데이터에 대한 추가 정보를 표시해야 할 수 있습니다. ToolTipText 속성을 사용하면 마우스 포인터를 패널 위에 놓을 때마다 정보를 표시할 수 있습니다.

StatusBar 컨트롤은 일반적으로 텍스트 정보를 표시하는 데 사용되지만, 사용자 자신의 고유한 형태로 StatusBarPanel에 표시할 수도 있습니다. Style 속성을 사용하면 StatusBarPanel을 그리는 방법을 지정할 수 있습니다. 기본적으로 Style 속성은 Text 속성의 값(Icon 속성에 아이콘이 지정된 경우에는 해당 아이콘)을 표시하는 데 사용됩니다. 이 속성을 OwnerDraw로 설정하면 패널에 사용자 자신의 정보를 그릴 수 있습니다. 또한 이 기능을 사용하면 패널에 진행률 표시줄이나 애니메이션 아이콘을 그릴 수 있습니다.

StatusBarPanel 클래스의 인스턴스를 만들면 읽기/쓰기 속성이 초기 값으로 설정됩니다. 이러한 값에 대한 목록은 StatusBarPanel 생성자를 참조하십시오.

예제

다음 코드 예제에서는 폼에 StatusBar 컨트롤을 만들고 StatusBarPanel 개체를 두 개 추가합니다. 첫 번째 StatusBarPanelpanel1에는 응용 프로그램에 대한 상태 텍스트가 표시됩니다. 두 번째 StatusBarPanelpanel2는 현재 날짜를 표시하고 StatusBarPanel 클래스의 ToolTipText 속성을 사용하여 현재 시간을 표시합니다. 예제에서는 ShowPanels 속성을 사용하여 표준 패널 대신 해당 패널이 표시되게 하고, Panels 속성을 사용하여 StatusBar.StatusBarPanelCollectionAdd 메서드에 액세스해서 StatusBar에 패널을 추가합니다. 또한 AutoSize, BorderStyle, ToolTipTextText 속성을 사용하여 StatusBarPanel 개체를 초기화합니다. 이 예제에서 정의되는 메서드는 Form의 생성자에서 정의되고 호출되는 것으로 가정합니다.

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
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:
   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.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.MarshalByRefObject
     System.ComponentModel.Component
      System.Windows.Forms.StatusBarPanel

스레드로부터의 안전성

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

StatusBarPanel 멤버
System.Windows.Forms 네임스페이스
StatusBarPanel 클래스