当前位置: 首页>>代码示例>>C#>>正文


C# StatusBarPanel.Text属性代码示例

本文整理汇总了C#中System.Windows.Forms.StatusBarPanel.Text属性的典型用法代码示例。如果您正苦于以下问题:C# StatusBarPanel.Text属性的具体用法?C# StatusBarPanel.Text怎么用?C# StatusBarPanel.Text使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在System.Windows.Forms.StatusBarPanel的用法示例。


在下文中一共展示了StatusBarPanel.Text属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateMyStatusBar

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);
}
开发者ID:.NET开发者,项目名称:System.Windows.Forms,代码行数:35,代码来源:StatusBarPanel.Text

示例2: StatusBar

//引入命名空间
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

public class FormWithStatusBar : System.Windows.Forms.Form
{
  private StatusBar statusBar = new StatusBar();
  private StatusBarPanel sbPnlPrompt = new StatusBarPanel();
  private StatusBarPanel sbPnlTime = new StatusBarPanel();

  private Timer timer1 = new Timer();
  private MainMenu mainMenu;
  private System.ComponentModel.Container components;

  public FormWithStatusBar()
  {
    InitializeComponent();

    timer1.Interval = 1000;
    timer1.Enabled = true;
    timer1.Tick += new EventHandler(timer1_Tick);
    this.MenuComplete += new EventHandler(StatusForm_MenuDone);
    BuildMenuSystem();
    BuildStatBar();
  }


  private void InitializeComponent()
  {
    this.components = new System.ComponentModel.Container();
    this.Size = new System.Drawing.Size(300,300);
    this.Text = "Form1";
  }
  [STAThread]
  static void Main() 
  {
    Application.Run(new FormWithStatusBar());
  }

  private void FileExit_Clicked(object sender, EventArgs e) 
  {    
    this.Close();
  }
    
  private void HelpAbout_Clicked(object sender, EventArgs e) 
  {
    sbPnlPrompt.Text = "Help";
  }
    
  private void FileExit_Selected(object sender, EventArgs e) 
  {
    sbPnlPrompt.Text = "Terminates this app";     
  }

  private void HelpAbout_Selected(object sender, EventArgs e) 
  {
    sbPnlPrompt.Text = "Displays app info";
  }

  private void StatusForm_MenuDone(object sender, EventArgs e) 
  {
    sbPnlPrompt.Text = "Ready";
  }

  private void timer1_Tick(object sender, EventArgs e) 
  {
    DateTime t = DateTime.Now;
    string s = t.ToLongTimeString() ;
    sbPnlTime.Text = s ;    
  }

  private void BuildMenuSystem()
  {
    mainMenu = new MainMenu();
    
    MenuItem miFile = mainMenu.MenuItems.Add("&File");          
    miFile.MenuItems.Add(new MenuItem("E&xit", new EventHandler(this.FileExit_Clicked),Shortcut.CtrlX));
    miFile.MenuItems[0].Select += new EventHandler(FileExit_Selected);

    MenuItem miHelp = mainMenu.MenuItems.Add("Help");  
    miHelp.MenuItems.Add(new MenuItem("&About",new EventHandler(this.HelpAbout_Clicked),Shortcut.CtrlA));
    miHelp.MenuItems[0].Select += new EventHandler(HelpAbout_Selected);

    this.Menu = mainMenu;      
  }

  private void BuildStatBar()
  {
    statusBar.ShowPanels = true;
    statusBar.Panels.AddRange(new StatusBarPanel[] {sbPnlPrompt, sbPnlTime});
    
    sbPnlPrompt.BorderStyle = StatusBarPanelBorderStyle.None;
    sbPnlPrompt.AutoSize = StatusBarPanelAutoSize.Spring;
    sbPnlPrompt.Width = 62;
    sbPnlPrompt.Text = "Ready";
    
    sbPnlTime.Alignment = HorizontalAlignment.Right;
    sbPnlTime.Width = 76;

    this.Controls.Add(statusBar);  
  }
}
开发者ID:C#程序员,项目名称:System.Windows.Forms,代码行数:106,代码来源:StatusBarPanel.Text


注:本文中的System.Windows.Forms.StatusBarPanel.Text属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。