congfeng02 发表于 2013-2-5 01:51:54

C#Windows简单控件使用源代码2

using System;using System.Drawing;using System.Windows.Forms;public class CForm : Form{    private Label label1;    private RadioButton radioButton1;    private RadioButton radioButton2;    private RadioButton radioButton3;    private RadioButton radioButton4;    private GroupBox groupBox1;    private GroupBox GropList2;    private CheckBox checkBox4;    private CheckBox checkBox3;    private CheckBox checkBox2;    private CheckBox checkBox1;    private Label label2;    private ListBox listBox1;    private Label label3;    private ComboBox comboBox1;    private ToolTip toolTip1;    private System.ComponentModel.IContainer components;    private ToolTip toolTip2;    private LinkLabel linkLabel1;    private LinkLabel linkLabel2;    private LinkLabel linkLabel3;    private Label label4;    private Timer timer1;    private MenuStrip menuStrip1;    private ToolStripMenuItem toolStripMenuItem1;    private ToolStripMenuItem a1ToolStripMenuItem;    private ToolStripMenuItem a2ToolStripMenuItem;    private ToolStripMenuItem a3ToolStripMenuItem;    private ToolStripMenuItem bbbToolStripMenuItem;    private ToolStripMenuItem cccToolStripMenuItem;    private ToolStripComboBox toolStripComboBox1;    private ToolStrip toolStrip1;    private ToolStripButton a1;    private ToolStripButton bbb;    private StatusStrip statusStrip1;    private ToolStripStatusLabel toolStripStatusLabel1;    private ToolStripStatusLabel toolStripStatusLabel2;    private int m_nLabelClick = 0;    public CForm()    {      InitializeComponent();      radioButton1.Checked = true;      this.toolTip1.SetToolTip(listBox1, "设置字体的list!");      this.toolTip1.SetToolTip(comboBox1, "设置字体的combox!");    }    public static void Main()    {      CForm objForm = new CForm();      Application.Run(objForm);    }    private void InitializeComponent()    {      this.components = new System.ComponentModel.Container();      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CForm));      this.label1 = new System.Windows.Forms.Label();      this.radioButton1 = new System.Windows.Forms.RadioButton();      this.radioButton2 = new System.Windows.Forms.RadioButton();      this.radioButton3 = new System.Windows.Forms.RadioButton();      this.radioButton4 = new System.Windows.Forms.RadioButton();      this.groupBox1 = new System.Windows.Forms.GroupBox();      this.GropList2 = new System.Windows.Forms.GroupBox();      this.checkBox4 = new System.Windows.Forms.CheckBox();      this.checkBox3 = new System.Windows.Forms.CheckBox();      this.checkBox2 = new System.Windows.Forms.CheckBox();      this.checkBox1 = new System.Windows.Forms.CheckBox();      this.label2 = new System.Windows.Forms.Label();      this.listBox1 = new System.Windows.Forms.ListBox();      this.label3 = new System.Windows.Forms.Label();      this.comboBox1 = new System.Windows.Forms.ComboBox();      this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);      this.toolTip2 = new System.Windows.Forms.ToolTip(this.components);      this.linkLabel1 = new System.Windows.Forms.LinkLabel();      this.linkLabel2 = new System.Windows.Forms.LinkLabel();      this.linkLabel3 = new System.Windows.Forms.LinkLabel();      this.label4 = new System.Windows.Forms.Label();      this.timer1 = new System.Windows.Forms.Timer(this.components);      this.menuStrip1 = new System.Windows.Forms.MenuStrip();      this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();      this.bbbToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();      this.cccToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();      this.a1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();      this.a2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();      this.a3ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();      this.toolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox();      this.toolStrip1 = new System.Windows.Forms.ToolStrip();      this.a1 = new System.Windows.Forms.ToolStripButton();      this.bbb = new System.Windows.Forms.ToolStripButton();      this.statusStrip1 = new System.Windows.Forms.StatusStrip();      this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();      this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();      this.groupBox1.SuspendLayout();      this.GropList2.SuspendLayout();      this.menuStrip1.SuspendLayout();      this.toolStrip1.SuspendLayout();      this.statusStrip1.SuspendLayout();      this.SuspendLayout();      //         // label1      //         this.label1.AutoSize = true;      this.label1.Location = new System.Drawing.Point(181, 46);      this.label1.Name = "label1";      this.label1.Size = new System.Drawing.Size(77, 12);      this.label1.TabIndex = 0;      this.label1.Text = "字体设置示例";      this.label1.Click += new System.EventHandler(this.label1_Click);      //         // radioButton1      //         this.radioButton1.AutoSize = true;      this.radioButton1.Location = new System.Drawing.Point(29, 39);      this.radioButton1.Name = "radioButton1";      this.radioButton1.Size = new System.Drawing.Size(47, 16);      this.radioButton1.TabIndex = 1;      this.radioButton1.Text = "宋体";      this.radioButton1.UseVisualStyleBackColor = true;      this.radioButton1.CheckedChanged += new System.EventHandler(this.RadioClick);      //         // radioButton2      //         this.radioButton2.AutoSize = true;      this.radioButton2.Location = new System.Drawing.Point(29, 61);      this.radioButton2.Name = "radioButton2";      this.radioButton2.Size = new System.Drawing.Size(47, 16);      this.radioButton2.TabIndex = 2;      this.radioButton2.Text = "仿宋";      this.radioButton2.UseVisualStyleBackColor = true;      this.radioButton2.CheckedChanged += new System.EventHandler(this.RadioClick);      //         // radioButton3      //         this.radioButton3.AutoSize = true;      this.radioButton3.Location = new System.Drawing.Point(29, 83);      this.radioButton3.Name = "radioButton3";      this.radioButton3.Size = new System.Drawing.Size(47, 16);      this.radioButton3.TabIndex = 3;      this.radioButton3.TabStop = true;      this.radioButton3.Text = "楷体";      this.radioButton3.UseVisualStyleBackColor = true;      this.radioButton3.CheckedChanged += new System.EventHandler(this.RadioClick);      //         // radioButton4      //         this.radioButton4.AutoSize = true;      this.radioButton4.Location = new System.Drawing.Point(29, 105);      this.radioButton4.Name = "radioButton4";      this.radioButton4.Size = new System.Drawing.Size(47, 16);      this.radioButton4.TabIndex = 4;      this.radioButton4.TabStop = true;      this.radioButton4.Text = "隶书";      this.radioButton4.UseVisualStyleBackColor = true;      this.radioButton4.CheckedChanged += new System.EventHandler(this.RadioClick);      //         // groupBox1      //         this.groupBox1.Controls.Add(this.radioButton2);      this.groupBox1.Controls.Add(this.radioButton4);      this.groupBox1.Controls.Add(this.radioButton3);      this.groupBox1.Controls.Add(this.radioButton1);      this.groupBox1.Location = new System.Drawing.Point(197, 116);      this.groupBox1.Name = "groupBox1";      this.groupBox1.Size = new System.Drawing.Size(200, 146);      this.groupBox1.TabIndex = 2;      this.groupBox1.TabStop = false;      this.groupBox1.Text = "Radio List";      //         // GropList2      //         this.GropList2.Controls.Add(this.checkBox4);      this.GropList2.Controls.Add(this.checkBox3);      this.GropList2.Controls.Add(this.checkBox2);      this.GropList2.Controls.Add(this.checkBox1);      this.GropList2.Location = new System.Drawing.Point(403, 116);      this.GropList2.Name = "GropList2";      this.GropList2.Size = new System.Drawing.Size(200, 146);      this.GropList2.TabIndex = 3;      this.GropList2.TabStop = false;      this.GropList2.Text = "爱好";      //         // checkBox4      //         this.checkBox4.AutoSize = true;      this.checkBox4.Location = new System.Drawing.Point(37, 104);      this.checkBox4.Name = "checkBox4";      this.checkBox4.Size = new System.Drawing.Size(48, 16);      this.checkBox4.TabIndex = 0;      this.checkBox4.Text = "游泳";      this.checkBox4.UseVisualStyleBackColor = true;      this.checkBox4.CheckedChanged += new System.EventHandler(this.CheckClick);      //         // checkBox3      //         this.checkBox3.AutoSize = true;      this.checkBox3.Location = new System.Drawing.Point(37, 82);      this.checkBox3.Name = "checkBox3";      this.checkBox3.Size = new System.Drawing.Size(48, 16);      this.checkBox3.TabIndex = 0;      this.checkBox3.Text = "跑步";      this.checkBox3.UseVisualStyleBackColor = true;      this.checkBox3.CheckedChanged += new System.EventHandler(this.CheckClick);      //         // checkBox2      //         this.checkBox2.AutoSize = true;      this.checkBox2.Location = new System.Drawing.Point(37, 60);      this.checkBox2.Name = "checkBox2";      this.checkBox2.Size = new System.Drawing.Size(48, 16);      this.checkBox2.TabIndex = 0;      this.checkBox2.Text = "足球";      this.checkBox2.UseVisualStyleBackColor = true;      this.checkBox2.CheckedChanged += new System.EventHandler(this.CheckClick);      //         // checkBox1      //         this.checkBox1.AutoSize = true;      this.checkBox1.Location = new System.Drawing.Point(37, 38);      this.checkBox1.Name = "checkBox1";      this.checkBox1.Size = new System.Drawing.Size(48, 16);      this.checkBox1.TabIndex = 0;      this.checkBox1.Text = "篮球";      this.checkBox1.UseVisualStyleBackColor = true;      this.checkBox1.CheckedChanged += new System.EventHandler(this.CheckClick);      //         // label2      //         this.label2.AutoSize = true;      this.label2.Location = new System.Drawing.Point(181, 70);      this.label2.Name = "label2";      this.label2.Size = new System.Drawing.Size(0, 12);      this.label2.TabIndex = 0;      this.label2.Click += new System.EventHandler(this.label1_Click);      //         // listBox1      //         this.listBox1.FormattingEnabled = true;      this.listBox1.ItemHeight = 12;      this.listBox1.Items.AddRange(new object[] {            "粗体",            "斜体",            "下划线",            "删除线"});      this.listBox1.Location = new System.Drawing.Point(24, 116);      this.listBox1.MultiColumn = true;      this.listBox1.Name = "listBox1";      this.listBox1.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;      this.listBox1.Size = new System.Drawing.Size(167, 148);      this.listBox1.TabIndex = 4;      this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);      //         // label3      //         this.label3.AutoSize = true;      this.label3.Location = new System.Drawing.Point(22, 46);      this.label3.Name = "label3";      this.label3.Size = new System.Drawing.Size(101, 12);      this.label3.TabIndex = 0;      this.label3.Text = "listbox 设置字体";      this.label3.Click += new System.EventHandler(this.label1_Click);      //         // comboBox1      //         this.comboBox1.FormattingEnabled = true;      this.comboBox1.Location = new System.Drawing.Point(199, 85);      this.comboBox1.Name = "comboBox1";      this.comboBox1.Size = new System.Drawing.Size(197, 20);      this.comboBox1.TabIndex = 5;      this.comboBox1.MouseHover += new System.EventHandler(this.ListOnMouseHover);      this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);      this.comboBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ListOnMouseMove);      //         // toolTip1      //         this.toolTip1.Popup += new System.Windows.Forms.PopupEventHandler(this.toolTip1_Popup);      //         // linkLabel1      //         this.linkLabel1.AutoSize = true;      this.linkLabel1.Location = new System.Drawing.Point(22, 317);      this.linkLabel1.Name = "linkLabel1";      this.linkLabel1.Size = new System.Drawing.Size(53, 12);      this.linkLabel1.TabIndex = 6;      this.linkLabel1.TabStop = true;      this.linkLabel1.Text = "我的博客";      this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);      //         // linkLabel2      //         this.linkLabel2.AutoSize = true;      this.linkLabel2.Location = new System.Drawing.Point(128, 317);      this.linkLabel2.Name = "linkLabel2";      this.linkLabel2.Size = new System.Drawing.Size(23, 12);      this.linkLabel2.TabIndex = 6;      this.linkLabel2.TabStop = true;      this.linkLabel2.Text = "c:\\";      this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel2_LinkClicked);      //         // linkLabel3      //         this.linkLabel3.AutoSize = true;      this.linkLabel3.Location = new System.Drawing.Point(256, 317);      this.linkLabel3.Name = "linkLabel3";      this.linkLabel3.Size = new System.Drawing.Size(41, 12);      this.linkLabel3.TabIndex = 6;      this.linkLabel3.TabStop = true;      this.linkLabel3.Text = "记事本";      this.linkLabel3.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel3_LinkClicked);      //         // label4      //         this.label4.AutoSize = true;      this.label4.Location = new System.Drawing.Point(416, 317);      this.label4.Name = "label4";      this.label4.Size = new System.Drawing.Size(59, 12);      this.label4.TabIndex = 7;      this.label4.Text = "现在时间:";      //         // timer1      //         this.timer1.Tick += new System.EventHandler(this.timer1_Tick);      //         // menuStrip1      //         this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {            this.toolStripMenuItem1,            this.bbbToolStripMenuItem,            this.cccToolStripMenuItem,            this.toolStripComboBox1});      this.menuStrip1.Location = new System.Drawing.Point(0, 0);      this.menuStrip1.Name = "menuStrip1";      this.menuStrip1.Size = new System.Drawing.Size(614, 24);      this.menuStrip1.TabIndex = 8;      this.menuStrip1.Text = "menuStrip1";      //         // toolStripMenuItem1      //         this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {            this.a1ToolStripMenuItem,            this.a2ToolStripMenuItem,            this.a3ToolStripMenuItem});      this.toolStripMenuItem1.Name = "toolStripMenuItem1";      this.toolStripMenuItem1.Size = new System.Drawing.Size(35, 20);      this.toolStripMenuItem1.Text = "aaa";      this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);      //         // bbbToolStripMenuItem      //         this.bbbToolStripMenuItem.Name = "bbbToolStripMenuItem";      this.bbbToolStripMenuItem.Size = new System.Drawing.Size(35, 20);      this.bbbToolStripMenuItem.Text = "bbb";      this.bbbToolStripMenuItem.Click += new System.EventHandler(this.bbbToolStripMenuItem_Click);      //         // cccToolStripMenuItem      //         this.cccToolStripMenuItem.Name = "cccToolStripMenuItem";      this.cccToolStripMenuItem.Size = new System.Drawing.Size(35, 20);      this.cccToolStripMenuItem.Text = "ccc";      //         // a1ToolStripMenuItem      //         this.a1ToolStripMenuItem.Name = "a1ToolStripMenuItem";      this.a1ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);      this.a1ToolStripMenuItem.Text = "a1";      this.a1ToolStripMenuItem.Click += new System.EventHandler(this.a1ToolStripMenuItem_Click);      //         // a2ToolStripMenuItem      //         this.a2ToolStripMenuItem.Name = "a2ToolStripMenuItem";      this.a2ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);      this.a2ToolStripMenuItem.Text = "a2";      //         // a3ToolStripMenuItem      //         this.a3ToolStripMenuItem.Name = "a3ToolStripMenuItem";      this.a3ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);      this.a3ToolStripMenuItem.Text = "a3";      //         // toolStripComboBox1      //         this.toolStripComboBox1.Items.AddRange(new object[] {            "com1",            "com2",            "com3"});      this.toolStripComboBox1.Name = "toolStripComboBox1";      this.toolStripComboBox1.Size = new System.Drawing.Size(121, 20);      this.toolStripComboBox1.Click += new System.EventHandler(this.toolStripComboBox1_Click);      //         // toolStrip1      //         this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {            this.a1,            this.bbb});      this.toolStrip1.Location = new System.Drawing.Point(0, 24);      this.toolStrip1.Name = "toolStrip1";      this.toolStrip1.Size = new System.Drawing.Size(614, 25);      this.toolStrip1.TabIndex = 9;      this.toolStrip1.Text = "toolStrip1";      //         // a1      //         this.a1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;      this.a1.Image = ((System.Drawing.Image)(resources.GetObject("a1.Image")));      this.a1.ImageTransparentColor = System.Drawing.Color.Magenta;      this.a1.Name = "a1";      this.a1.Size = new System.Drawing.Size(23, 22);      this.a1.Text = "toolStripButton1";      this.a1.Click += new System.EventHandler(this.a1ToolStripMenuItem_Click);      //         // bbb      //         this.bbb.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;      this.bbb.Image = ((System.Drawing.Image)(resources.GetObject("bbb.Image")));      this.bbb.ImageTransparentColor = System.Drawing.Color.Magenta;      this.bbb.Name = "bbb";      this.bbb.Size = new System.Drawing.Size(23, 22);      this.bbb.Text = "toolStripButton1";      this.bbb.Click += new System.EventHandler(this.bbbToolStripMenuItem_Click);      //         // statusStrip1      //         this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {            this.toolStripStatusLabel1,            this.toolStripStatusLabel2});      this.statusStrip1.Location = new System.Drawing.Point(0, 353);      this.statusStrip1.Name = "statusStrip1";      this.statusStrip1.Size = new System.Drawing.Size(614, 22);      this.statusStrip1.TabIndex = 10;      this.statusStrip1.Text = "statusStrip1";      //         // toolStripStatusLabel1      //         this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";      this.toolStripStatusLabel1.Size = new System.Drawing.Size(131, 17);      this.toolStripStatusLabel1.Text = "toolStripStatusLabel1";      this.toolStripStatusLabel1.Click += new System.EventHandler(this.toolStripStatusLabel1_Click);      //         // toolStripStatusLabel2      //         this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";      this.toolStripStatusLabel2.Size = new System.Drawing.Size(131, 17);      this.toolStripStatusLabel2.Text = "toolStripStatusLabel2";      this.toolStripStatusLabel2.Click += new System.EventHandler(this.toolStripStatusLabel2_Click);      //         // CForm      //         this.ClientSize = new System.Drawing.Size(614, 375);      this.Controls.Add(this.statusStrip1);      this.Controls.Add(this.toolStrip1);      this.Controls.Add(this.label4);      this.Controls.Add(this.linkLabel3);      this.Controls.Add(this.linkLabel2);      this.Controls.Add(this.linkLabel1);      this.Controls.Add(this.comboBox1);      this.Controls.Add(this.listBox1);      this.Controls.Add(this.GropList2);      this.Controls.Add(this.groupBox1);      this.Controls.Add(this.label2);      this.Controls.Add(this.label3);      this.Controls.Add(this.label1);      this.Controls.Add(this.menuStrip1);      this.MainMenuStrip = this.menuStrip1;      this.Name = "CForm";      this.Text = "My Form";      this.Load += new System.EventHandler(this.CForm_Load);      this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);      this.groupBox1.ResumeLayout(false);      this.groupBox1.PerformLayout();      this.GropList2.ResumeLayout(false);      this.GropList2.PerformLayout();      this.menuStrip1.ResumeLayout(false);      this.menuStrip1.PerformLayout();      this.toolStrip1.ResumeLayout(false);      this.toolStrip1.PerformLayout();      this.statusStrip1.ResumeLayout(false);      this.statusStrip1.PerformLayout();      this.ResumeLayout(false);      this.PerformLayout();    }    private void label1_Click(object sender, EventArgs e)    {      m_nLabelClick++;                switch (m_nLabelClick % 3)      {            case 0:                this.label1.ForeColor = Color.Red;                this.label1.Text = "my color is red";                break;            case 1:                this.label1.ForeColor = Color.Green;                this.label1.Text = "my color is green";                break;            default:                this.label1.ForeColor = Color.Blue;                this.label1.Text = "my color is blue";                break;      }      }    private void RadioClick(object sender, EventArgs e)    {      if (radioButton1 == sender)      {            this.label1.Font = new Font("宋体", label1.Font.Size);      }      else if (radioButton2 == sender)      {            this.label1.Font = new Font("仿宋", label1.Font.Size);      }      else if (radioButton3 == sender)      {            this.label1.Font = new Font("楷体_GB2312", label1.Font.Size);      }      else      {            this.label1.Font = new Font("隶书", label1.Font.Size);      }    }    private void CheckClick(object sender, EventArgs e)    {      this.label2.Text = "我的爱好: ";                if (checkBox1.Checked)      {            this.label2.Text += "篮球 ";      }                if (checkBox2.Checked)      {            this.label2.Text += "足球 ";      }                if (checkBox3.Checked)      {            this.label2.Text += "跑步 ";      }                if (checkBox4.Checked)      {            this.label2.Text += "游泳 ";      }    }    private void listBox1_SelectedIndexChanged(object sender, EventArgs e)    {      int nStyle = 0;      int i = 0;      int k = 1;      for (i = 0; i < listBox1.Items.Count; i++)      {            if (listBox1.GetSelected(i))            {                nStyle |= k;            }            else            {                nStyle &= ~k;            }            k *= 2;      }      FontStyle styleFont = (FontStyle)nStyle;      label3.Font = new Font(label1.Font.Name,9, styleFont);    }    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)    {      label1.Font = new Font(comboBox1.Text, 9);    }    private void CForm_Load(object sender, EventArgs e)    {      //Families是类FontFamily的一个静态属性,得到操作系统中所使用的所有字体名      FontFamily[] arrFontFamily = FontFamily.Families;      foreach(FontFamily familyFont in arrFontFamily)      {            comboBox1.Items.Add(familyFont.Name);      }      timer1.Interval = 100;      timer1.Enabled = true;      label4.Text = DateTime.Now.ToString();    }    private void toolTip1_Popup(object sender, PopupEventArgs e)    {      DateTime dt1 = new DateTime(2009, 10, 01);      DateTime dt2 = DateTime.Now;      TimeSpan ts = dt1 - dt2;      MessageBox.Show(ts.ToString());      DateTime dt3 = dt1 - new TimeSpan(1, 1, 1, 1);      MessageBox.Show(dt3.ToString());    }    private void ListOnMouseHover(object sender, EventArgs e)    {      //this.toolTip1.SetToolTip(listBox1, "设置字体的list!");    }    private void ListOnMouseMove(object sender, MouseEventArgs e)    {      //this.toolTip1.SetToolTip(listBox1, "设置字体的list!");    }    private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)    {      linkLabel1.LinkVisited = true;      System.Diagnostics.Process.Start("http://blog.csdn.net/andylin02");    }    private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)    {      linkLabel2.LinkVisited = true;      System.Diagnostics.Process.Start("c:/");    }    private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)    {      linkLabel3.LinkVisited = true;      System.Diagnostics.Process.Start("notepad");    }    private void timer1_Tick(object sender, EventArgs e)    {      label4.Text = DateTime.Now.ToString();      toolStripStatusLabel1.Text = DateTime.Now.ToString();    }    private void toolStripMenuItem1_Click(object sender, EventArgs e)    {    }    private void a1ToolStripMenuItem_Click(object sender, EventArgs e)    {      MessageBox.Show("aaa = > a1");    }    private void bbbToolStripMenuItem_Click(object sender, EventArgs e)    {      MessageBox.Show("bbb");    }    private void toolStripComboBox1_Click(object sender, EventArgs e)    {    }    private void toolStripStatusLabel1_Click(object sender, EventArgs e)    {      toolStripStatusLabel1.Text = DateTime.Now.ToString();    }    private void toolStripStatusLabel2_Click(object sender, EventArgs e)    {      toolStripStatusLabel2.Text = "鼠标位置:";    }    private void OnMouseMove(object sender, MouseEventArgs e)    {      toolStripStatusLabel2.Text = "(" + e.X.ToString() + ", " + e.Y.ToString() + ")";    }}
页: [1]
查看完整版本: C#Windows简单控件使用源代码2