StatusBarPanel StatusBarPanel StatusBarPanel StatusBarPanel Class

定义

表示 StatusBar 控件中的一个面板。Represents a panel in a StatusBar control. 虽然 StatusStrip 控件对以前版本的 StatusBar 控件的功能进行替换和添加,但是考虑到向后兼容性和将来的使用(如果您选择),仍然保留了 StatusBarAlthough the StatusStrip control replaces and adds functionality to the StatusBar control of previous versions, StatusBar is retained for both backward compatibility and future use if you choose.

public ref class StatusBarPanel : System::ComponentModel::Component, System::ComponentModel::ISupportInitialize
public class StatusBarPanel : System.ComponentModel.Component, System.ComponentModel.ISupportInitialize
type StatusBarPanel = class
    inherit Component
    interface ISupportInitialize
Public Class StatusBarPanel
Inherits Component
Implements ISupportInitialize
继承
实现

示例

下面的代码示例将创建StatusBar控件在窗体上,添加两个StatusBarPanel对象。The following code example creates a StatusBar control on a form and adds two StatusBarPanel objects. 第一个StatusBarPanel名为panel1,显示应用程序的状态文本。The first StatusBarPanel, named panel1, displays status text for an application. 第二个StatusBarPanel名为panel2,显示当前日期,并使用ToolTipText属性的StatusBarPanel类,以显示当前时间。The second StatusBarPanel, named panel2, displays the current date and uses the ToolTipText property of the StatusBarPanel class to display the current time. 该示例使用ShowPanels属性以确保显示多个面板而不是标准的面板中,并使用Panels属性来访问Add方法StatusBar.StatusBarPanelCollection若要添加到面板StatusBarThe example uses the ShowPanels property to ensure that the panels are displayed instead of a standard panel, and it uses the Panels property to access the Add method of the StatusBar.StatusBarPanelCollection to add the panels to the StatusBar. 此示例还使用AutoSizeBorderStyleToolTipText,和Text属性来初始化StatusBarPanel对象。The example also uses the AutoSize, BorderStyle, ToolTipText, and Text properties to initialize the StatusBarPanel objects. 此示例假定在示例中定义的方法是定义和调用的构造函数从FormThis example assumes that the method defined in the example is defined and called from the constructor of a 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表示中的单个面板StatusBar.StatusBarPanelCollectionStatusBar控件。A StatusBarPanel represents an individual panel in the StatusBar.StatusBarPanelCollection of a StatusBar control. 一个StatusBarPanel可以包含文本和/或可用于反映应用程序的状态的图标。A StatusBarPanel can contain text and/or an icon that can be used to reflect the status of an application. 使用StatusBar.StatusBarPanelCollection,可通过访问StatusBar.Panels的属性StatusBar控件,用来检索、 添加或删除个人StatusBarPanelUse the StatusBar.StatusBarPanelCollection, accessible through the StatusBar.Panels property of a StatusBar control, to retrieve, add, or remove an individual StatusBarPanel.

StatusBarPanel提供的属性,使你能够修改中的面板的显示行为StatusBar控件。The StatusBarPanel provides properties that enable you to modify the display behavior of a panel within a StatusBar control. 可以使用Icon属性来显示一个面板中的图标。You can use the Icon property to display an icon within a panel. 此属性可以用于提供的图形表示形式的应用程序中的状态。This property can be used to provide a graphical representation of state in an application. Alignment属性可用于指定文本和/或图标的面板内的对齐方式。The Alignment property enables you to specify how text and/or an icon is aligned within the panel. 若要确保,在面板的大小以适应面板的文本,可以使用AutoSize空间中的属性自动调整大小以适应面板的文本或以填充剩余的面板StatusBar控件。To ensure that your panel is sized properly to fit the text of the panel, you can use the AutoSize property to automatically resize the panel to fit the text of the panel or to fill the remaining space within the StatusBar control. MinWidth属性可用于指定要确保它不会小于其用来显示的数据的面板的最小宽度。The MinWidth property enables you to specify a minimum width for the panel to ensure that it does not get smaller than the data it is intended to display.

StatusBar控件通常用于显示帮助信息或有关你的应用程序的状态信息。The StatusBar control is typically used to display Help information or state information about your application. 通常情况下,务必要显示在面板中显示的数据有关的其他信息。Often, it is important to display additional information about data that is presented in a panel. 可以使用ToolTipText属性时鼠标指针停留在一个面板上显示信息。You can use the ToolTipText property to display information whenever the mouse pointer rests on a panel.

尽管StatusBar控件通常用于显示文本信息,还可以提供自己的类型的显示StatusBarPanelAlthough the StatusBar control is typically used to display textual information, you can also provide your own type of display to a StatusBarPanel. Style属性可用于指定如何StatusBarPanel将绘制。The Style property enables you to specify how the StatusBarPanel will be drawn. 默认情况下Style属性用于显示的值Text属性 (一个图标,如果在指定Icon属性)。By default, the Style property is used to display the value of the Text property (and an icon, if specified in the Icon property). 如果该属性设置为OwnerDraw,可以到面板中绘制您自己的信息。If the property is set to OwnerDraw, you can draw your own information into the panel. 此功能可用于在面板中绘制进度栏或动画的图标。You can use this feature to draw a progress bar or an animated icon in the panel.

创建的实例时StatusBarPanel类,读/写属性设置为初始值。When you create an instance of the StatusBarPanel class, the read/write properties are set to initial values. 有关这些值的列表,请参阅StatusBarPanel构造函数。For a list of these values, see the StatusBarPanel constructor.

构造函数

StatusBarPanel() StatusBarPanel() StatusBarPanel() StatusBarPanel()

初始化 StatusBarPanel 类的新实例。Initializes a new instance of the StatusBarPanel class.

属性

Alignment Alignment Alignment Alignment

获取或设置状态栏面板中文本和图标的对齐方式。Gets or sets the alignment of text and icons within the status bar panel.

AutoSize AutoSize AutoSize AutoSize

获取或设置一个值,该值指示是否自动调整状态栏面板的大小。Gets or sets a value indicating whether the status bar panel is automatically resized.

BorderStyle BorderStyle BorderStyle BorderStyle

获取或设置状态栏面板的边框样式。Gets or sets the border style of the status bar panel.

CanRaiseEvents CanRaiseEvents CanRaiseEvents CanRaiseEvents

获取一个指示组件是否可以引发事件的值。Gets a value indicating whether the component can raise an event.

(Inherited from Component)
Container Container Container Container

获取 IContainer,它包含 ComponentGets the IContainer that contains the Component.

(Inherited from Component)
DesignMode DesignMode DesignMode DesignMode

获取一个值,用以指示 Component 当前是否处于设计模式。Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
Events Events Events Events

获取附加到此 Component 的事件处理程序的列表。Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
Icon Icon Icon Icon

获取或设置要显示在状态栏面板中的图标。Gets or sets the icon to display within the status bar panel.

MinWidth MinWidth MinWidth MinWidth

获取或设置 StatusBar 控件中状态栏面板的最小允许宽度。Gets or sets the minimum allowed width of the status bar panel within the StatusBar control.

Name Name Name Name

获取或设置应用于 StatusBarPanel 的名称。Gets or sets the name to apply to the StatusBarPanel.

Parent Parent Parent Parent

获取承载状态栏面板的 StatusBar 控件。Gets the StatusBar control that hosts the status bar panel.

Site Site Site Site

获取或设置 ComponentISiteGets or sets the ISite of the Component.

(Inherited from Component)
Style Style Style Style

获取或设置状态栏面板的样式。Gets or sets the style of the status bar panel.

Tag Tag Tag Tag

获取或设置包含有关 StatusBarPanel 的数据的对象。Gets or sets an object that contains data about the StatusBarPanel.

Text Text Text Text

获取或设置状态栏面板的文本。Gets or sets the text of the status bar panel.

ToolTipText ToolTipText ToolTipText ToolTipText

获取或设置与状态栏面板关联的工具提示文本。Gets or sets ToolTip text associated with the status bar panel.

Width Width Width Width

获取或设置 StatusBar 控件中状态栏面板的宽度。Gets or sets the width of the status bar panel within the StatusBar control.

方法

BeginInit() BeginInit() BeginInit() BeginInit()

开始 StatusBarPanel 的初始化。Begins the initialization of a StatusBarPanel.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

释放由 Component 使用的所有资源。Releases all resources used by the Component.

(Inherited from Component)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

释放由 StatusBarPanel 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the StatusBarPanel and optionally releases the managed resources.

EndInit() EndInit() EndInit() EndInit()

结束 StatusBarPanel 的初始化。Ends the initialization of a StatusBarPanel.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

返回一个对象,该对象表示由 Component 或它的 Container 提供的服务。Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
ToString() ToString() ToString() ToString()

检索一个字符串,该字符串包含面板的信息。Retrieves a string that contains information about the panel.

事件

Disposed Disposed Disposed Disposed

当通过调用 Dispose() 方法释放组件时发生。Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)

适用于

另请参阅