更新 : 2007 年 11 月
Windows ステータス バー コントロールを表します。ToolStripStatusLabel は以前のバージョンの StatusBar コントロールの機能を置換または追加しますが、選択により、下位互換性および将来の使用のために StatusBar を保持することもできます。
名前空間 :
System.Windows.Forms アセンブリ :
System.Windows.Forms (System.Windows.Forms.dll 内)
<ComVisibleAttribute(True)> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
Public Class StatusBar _
Inherits Control
Dim instance As StatusBar
[ComVisibleAttribute(true)]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
public class StatusBar : Control
[ComVisibleAttribute(true)]
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
public ref class StatusBar : public Control
/** @attribute ComVisibleAttribute(true) */
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */
public class StatusBar extends Control
public class StatusBar extends Control
通常、StatusBar コントロールは、それぞれがテキストまたはアイコン (またはその両方) を表示する StatusBarPanel オブジェクトで構成されます。また、オーナー描画パネルを提供して、アプリケーションの状態を表示するプログレス バーや一連のイメージなどのカスタム パネルも提供できます。StatusBar コントロールは、通常は、Form に表示されているオブジェクトに関する情報、オブジェクトのコンポーネント、またはアプリケーション内のそのオブジェクトの操作に関連したコンテキスト情報を表示します。
StatusBar コントロールは、コントロールの外観をカスタマイズするためのプロパティを提供します。StatusBar が、サイズ変更のできるフォームに表示される場合は、SizingGrip プロパティを使用すると、フォームの右下隅にサイズ変更グリップを表示して、サイズ変更のできるフォームであることをユーザーに示すことができます。ShowPanels プロパティを使用すると、StatusBar 内にパネルを表示したり、コントロールの Text プロパティの値だけを表示したりできます。
既定の StatusBar にはパネルがありません。StatusBar にパネルを追加するには、コントロールの Panels プロパティを通じてアクセスできる StatusBar..::.StatusBarPanelCollection クラスの Add メソッドを使用します。また、Panels プロパティを通じて提供される StatusBar..::.StatusBarPanelCollection オブジェクトを使用して、コントロールからパネルを削除し、特定の StatusBarPanel にアクセスしてパネルを操作することもできます。
StatusBar コントロール内の StatusBarPanel オブジェクトがいつクリックされたかを確認する場合は、PanelClick イベントのイベント ハンドラを作成します。パネル上でオーナー描画操作を実行するには、DrawItem イベントのイベント ハンドラを作成します。イベント ハンドラに渡されるイベント データは、描画対象のパネルおよび描画タスクを実行するために使用する Graphics オブジェクトに関する情報を提供します。
StatusBar のインスタンスを作成すると、読み書き可能なプロパティが初期値に設定されます。これらの初期値の一覧については、StatusBar コンストラクタのトピックを参照してください。
フォームに StatusBar コントロールを作成し、2 つの StatusBarPanel オブジェクトを追加するコード例を次に示します。StatusBarPanel オブジェクトの 1 つである panel1 は、アプリケーションのステータス テキストを表示します。panel2 という名前のもう一方の StatusBarPanel は、現在の日付を表示し、StatusBarPanel クラスの ToolTipText プロパティを使用して現在の時刻を表示します。この例では、標準パネルの代わりにこれらのパネルが表示されるようにするために ShowPanels プロパティを使用し、さらに Panels プロパティを使用して StatusBar..::.StatusBarPanelCollection の Add メソッドにアクセスして StatusBar にパネルを追加します。また、StatusBarPanel オブジェクトを初期化するために、AutoSize、BorderStyle、ToolTipText、Text の各プロパティも使用します。この例は、コード内で定義されたメソッドが定義されており、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..::.Control
System.Windows.Forms..::.StatusBar
この型のすべてのパブリック static (Visual Basic では Shared) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Pocket PC
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
.NET Framework
サポート対象 : 3.5、3.0、2.0、1.1、1.0
.NET Compact Framework
サポート対象 : 3.5、2.0、1.0
参照