Language

StatusBar.ShowPanels プロパティ

定義

コントロールに追加されたパネルを表示するかどうかを示す値を取得または設定します。

public:
 property bool ShowPanels { bool get(); void set(bool value); };
public bool ShowPanels { get; set; }
member this.ShowPanels : bool with get, set
Public Property ShowPanels As Boolean

プロパティ値

true パネルが表示されている場合。それ以外の場合は false。 既定値は false です。

例

次のコード例では、フォームに StatusBar コントロールを作成し、2 つの StatusBarPanel オブジェクトを追加します。 StatusBarPanelという名前のpanel1 オブジェクトの 1 つに、アプリケーションの状態テキストが表示されます。 StatusBarPanelという名前の 2 番目のpanel2は、現在の日付を表示し、ToolTipText クラスの StatusBarPanel プロパティを使用して現在の時刻を表示します。 この例では、ShowPanels プロパティを使用して、パネルが標準パネルではなく表示されるようにし、Panels プロパティを使用してAddのStatusBar.StatusBarPanelCollection メソッドにアクセスしてパネルをStatusBarに追加します。 また、この例では、 AutoSize、 BorderStyle、 ToolTipText、および Text プロパティを使用して、 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

注釈

既定では、 StatusBar コントロールには、パネルを使用せずに Text プロパティの値が表示されます。 ShowPanelsを true に設定すると、StatusBarPanel コントロールで指定されたStatusBar オブジェクトが表示されます。 StatusBar クラスのインスタンスを作成するときに、最初はパネルは作成されません。 StatusBar クラスのAdd メソッドを使用して、パネルをStatusBar.StatusBarPanelCollection コントロールに追加できます。 このコレクション クラスには、Panelsの StatusBar プロパティを使用してアクセスできます。

適用対象

こちらもご覧ください