本文整理汇总了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);
}
示例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;
}
}