Share via


StatusBarPanelClickEventArgs.StatusBarPanel 属性

定义

获取要绘制的 StatusBarPanel

public:
 property System::Windows::Forms::StatusBarPanel ^ StatusBarPanel { System::Windows::Forms::StatusBarPanel ^ get(); };
public System.Windows.Forms.StatusBarPanel StatusBarPanel { get; }
member this.StatusBarPanel : System.Windows.Forms.StatusBarPanel
Public ReadOnly Property StatusBarPanel As StatusBarPanel

属性值

要绘制的 StatusBarPanel

示例

下面的代码示例演示了此成员的用法。 在此示例中,事件处理程序报告事件的发生情况 StatusBar.PanelClick 。 此报表可帮助你了解事件发生的时间,并可以帮助你进行调试。 若要报告多个事件或频繁发生的事件,请考虑将 MessageBox.Show 替换为 Console.WriteLine 或将消息追加到多行 TextBox

若要运行示例代码,请将其粘贴到包含名为 StatusBar1的 类型的StatusBar实例的项目中。 然后,确保事件处理程序与 StatusBar.PanelClick 事件相关联。

private void StatusBar1_PanelClick(Object sender, StatusBarPanelClickEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "StatusBarPanel", e.StatusBarPanel );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Button", e.Button );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Clicks", e.Clicks );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "X", e.X );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Y", e.Y );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Delta", e.Delta );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Location", e.Location );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "PanelClick Event" );
}
Private Sub StatusBar1_PanelClick(sender as Object, e as StatusBarPanelClickEventArgs) _ 
     Handles StatusBar1.PanelClick

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "StatusBarPanel", e.StatusBarPanel)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Button", e.Button)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Clicks", e.Clicks)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "X", e.X)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Y", e.Y)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Delta", e.Delta)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Location", e.Location)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"PanelClick Event")

End Sub

注解

属性 StatusBarPanel 使你能够获取 StatusBarPanel 单击的 。 可以在控件的 事件事件处理程序PanelClickStatusBar中使用它来执行任务,例如在单击控件中的 StatusBarStatusBarPanel显示自定义对话框。

适用于

另请参阅