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


C# StatusBar.ShowPanels属性代码示例

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


在下文中一共展示了StatusBar.ShowPanels属性的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,代码来源:StatusBar.ShowPanels

示例2: Main

//引入命名空间
using System;
using System.Drawing;
using System.Windows.Forms;
   
class MenuHelpFirstTry: Form
{
     StatusBarPanel sbpMenuHelp;
     string         strSavePanelText;
   
     public static void Main()
     {
          Application.Run(new MenuHelpFirstTry());
     }
     public MenuHelpFirstTry()
     {
   
          StatusBar sb = new StatusBar();
          sb.Parent = this;
          sb.ShowPanels = true;
   
          sbpMenuHelp = new StatusBarPanel();
          sbpMenuHelp.Text = "Ready";
          sbpMenuHelp.AutoSize = StatusBarPanelAutoSize.Spring;
   
          sb.Panels.Add(sbpMenuHelp);
   
          Menu = new MainMenu();
          EventHandler ehSelect = new EventHandler(MenuOnSelect);
          
          MenuItem mi = new MenuItem("File");
          mi.Select += ehSelect;
          Menu.MenuItems.Add(mi);
   
          mi = new MenuItem("Open");
          mi.Select += ehSelect;
          Menu.MenuItems[0].MenuItems.Add(mi);
   
          mi = new MenuItem("Close");
          mi.Select += ehSelect;
          Menu.MenuItems[0].MenuItems.Add(mi);
   
          mi = new MenuItem("Save");
          mi.Select += ehSelect;
          Menu.MenuItems[0].MenuItems.Add(mi);
   
          mi = new MenuItem("Edit");
          mi.Select += ehSelect;
          Menu.MenuItems.Add(mi);
   
          mi = new MenuItem("Cut");
          mi.Select += ehSelect;
          Menu.MenuItems[1].MenuItems.Add(mi);
          
          mi = new MenuItem("Copy");
          mi.Select += ehSelect;
          Menu.MenuItems[1].MenuItems.Add(mi);
   
          mi = new MenuItem("Paste");
          mi.Select += ehSelect;
          Menu.MenuItems[1].MenuItems.Add(mi);
     }
     protected override void OnMenuStart(EventArgs ea)
     {
          strSavePanelText = sbpMenuHelp.Text;
     }
     protected override void OnMenuComplete(EventArgs ea)
     {
          sbpMenuHelp.Text = strSavePanelText;
     }
     void MenuOnSelect(object obj, EventArgs ea)
     {
          MenuItem mi = (MenuItem) obj;
          string   str;
   
          switch (mi.Text)
          {
              case "File":   str = "file";    break;
              case "Open":   str = "Open";         break;
              case "Close":  str = "Close";        break;
              case "Save":   str = "Save";         break;
              case "Edit":   str = "edit";  break;
              case "Cut":    str = "cut";         break;
              case "Copy":   str = "Copy";                          break;
              case "Paste":  str = "Paste";        break;
              default:       str = "";                                   break;
          }
   
          sbpMenuHelp.Text = str;
     }
}
开发者ID:C#程序员,项目名称:System.Windows.Forms,代码行数:91,代码来源:StatusBar.ShowPanels


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