📄 form1.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace StatusBarDemo
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.LinkLabel linkLabel2;
private System.Windows.Forms.LinkLabel linkLabel3;
private System.Windows.Forms.LinkLabel linkLabel4;
private System.Windows.Forms.StatusBarPanel statusBarPanel1;
private System.Windows.Forms.StatusBarPanel statusBarPanel2;
private System.Windows.Forms.StatusBarPanel statusBarPanel3;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel();
this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
this.linkLabel4 = new System.Windows.Forms.LinkLabel();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.linkLabel2 = new System.Windows.Forms.LinkLabel();
this.linkLabel3 = new System.Windows.Forms.LinkLabel();
this.statusBar1 = new System.Windows.Forms.StatusBar();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();
this.SuspendLayout();
//
// statusBarPanel1
//
this.statusBarPanel1.ToolTipText = "显示链接的网址";
this.statusBarPanel1.Width = 250;
//
// statusBarPanel3
//
this.statusBarPanel3.Text = "Y:";
this.statusBarPanel3.ToolTipText = "鼠标纵坐标";
this.statusBarPanel3.Width = 40;
//
// statusBarPanel2
//
this.statusBarPanel2.Text = "X:";
this.statusBarPanel2.ToolTipText = "鼠标横坐标";
this.statusBarPanel2.Width = 40;
//
// linkLabel4
//
this.linkLabel4.LinkVisited = true;
this.linkLabel4.Location = new System.Drawing.Point(32, 168);
this.linkLabel4.Name = "linkLabel4";
this.linkLabel4.TabIndex = 1;
this.linkLabel4.TabStop = true;
this.linkLabel4.Text = "Sohu搜索引擎";
this.linkLabel4.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel4_LinkClicked);
this.linkLabel4.MouseHover += new System.EventHandler(this.linkLabel4_MouseHover);
this.linkLabel4.MouseLeave += new System.EventHandler(this.linkLabel4_MouseLeave);
//
// linkLabel1
//
this.linkLabel1.LinkVisited = true;
this.linkLabel1.Location = new System.Drawing.Point(32, 40);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.TabIndex = 1;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "微软公司";
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
this.linkLabel1.MouseHover += new System.EventHandler(this.linkLabel1_MouseHover);
this.linkLabel1.MouseLeave += new System.EventHandler(this.linkLabel1_MouseLeave);
//
// linkLabel2
//
this.linkLabel2.LinkVisited = true;
this.linkLabel2.Location = new System.Drawing.Point(32, 80);
this.linkLabel2.Name = "linkLabel2";
this.linkLabel2.Size = new System.Drawing.Size(144, 23);
this.linkLabel2.TabIndex = 1;
this.linkLabel2.TabStop = true;
this.linkLabel2.Text = "微软中国有限公司";
this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel2_LinkClicked);
this.linkLabel2.MouseHover += new System.EventHandler(this.linkLabel2_MouseHover);
this.linkLabel2.MouseLeave += new System.EventHandler(this.linkLabel2_MouseLeave);
//
// linkLabel3
//
this.linkLabel3.LinkVisited = true;
this.linkLabel3.Location = new System.Drawing.Point(32, 120);
this.linkLabel3.Name = "linkLabel3";
this.linkLabel3.Size = new System.Drawing.Size(160, 23);
this.linkLabel3.TabIndex = 1;
this.linkLabel3.TabStop = true;
this.linkLabel3.Text = "北京希望电子出版社";
this.linkLabel3.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel3_LinkClicked);
this.linkLabel3.MouseHover += new System.EventHandler(this.linkLabel3_MouseHover);
this.linkLabel3.MouseLeave += new System.EventHandler(this.linkLabel3_MouseLeave);
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 253);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
this.statusBarPanel1,
this.statusBarPanel2,
this.statusBarPanel3});
this.statusBar1.ShowPanels = true;
this.statusBar1.Size = new System.Drawing.Size(352, 20);
this.statusBar1.TabIndex = 0;
this.statusBar1.Text = "statusBar1";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(352, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.linkLabel4,
this.linkLabel3,
this.linkLabel2,
this.linkLabel1,
this.statusBar1});
this.Name = "Form1";
this.Text = "状态栏演示示例";
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://www.Microsoft.com");
}
private void linkLabel1_MouseHover(object sender, System.EventArgs e)
{
statusBarPanel1.Text = "http://www.Microsoft.com";
}
private void linkLabel1_MouseLeave(object sender, System.EventArgs e)
{
statusBarPanel1.Text = "";
}
private void linkLabel2_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://www.Microsoft.com/china");
}
private void linkLabel2_MouseHover(object sender, System.EventArgs e)
{
statusBarPanel1.Text = "http://www.Microsoft.com/china";
}
private void linkLabel2_MouseLeave(object sender, System.EventArgs e)
{
statusBarPanel1.Text = "";
}
private void linkLabel3_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://www.bhp.com.cn");
}
private void linkLabel3_MouseHover(object sender, System.EventArgs e)
{
statusBarPanel1.Text = "http://www.bhp.com.cn";
}
private void linkLabel3_MouseLeave(object sender, System.EventArgs e)
{
statusBarPanel1.Text = "";
}
private void linkLabel4_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://www.sohu.com");
}
private void linkLabel4_MouseHover(object sender, System.EventArgs e)
{
statusBarPanel1.Text = "http://www.sohu.com";
}
private void linkLabel4_MouseLeave(object sender, System.EventArgs e)
{
statusBarPanel1.Text = "";
}
private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
statusBarPanel2.Text = "X:" + e.X.ToString();
statusBarPanel3.Text = "Y:" + e.Y.ToString();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -