博客
关于我
游戏开发 XNAGame-005 事件处理函数的参数的作用
阅读量:328 次
发布时间:2019-03-03

本文共 4179 字,大约阅读时间需要 13 分钟。

form1.cs

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace XNAGame_005{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private void button1_Click(object sender, EventArgs e)        {            //事件处理函数,参数一表示触发的对象是谁            if (sender == button1)            {                label1.ForeColor = Color.Blue;            }            else if (sender == button2)            {                label1.ForeColor = Color.Black;            }        }        private void button3_Click(object sender, EventArgs e)        {            this.Close();        }    }}

form1.design.cs

namespace XNAGame_005{    partial class Form1    {        ///         /// 必需的设计器变量。        ///         private System.ComponentModel.IContainer components = null;        ///         /// 清理所有正在使用的资源。        ///         /// 如果应释放托管资源,为 true;否则为 false。        protected override void Dispose(bool disposing)        {            if (disposing && (components != null))            {                components.Dispose();            }            base.Dispose(disposing);        }        #region Windows 窗体设计器生成的代码        ///         /// 设计器支持所需的方法 - 不要        /// 使用代码编辑器修改此方法的内容。        ///         private void InitializeComponent()        {            this.label1 = new System.Windows.Forms.Label();            this.button1 = new System.Windows.Forms.Button();            this.button2 = new System.Windows.Forms.Button();            this.button3 = new System.Windows.Forms.Button();            this.SuspendLayout();            //             // label1            //             this.label1.AutoSize = true;            this.label1.Location = new System.Drawing.Point(46, 31);            this.label1.Name = "label1";            this.label1.Size = new System.Drawing.Size(77, 12);            this.label1.TabIndex = 0;            this.label1.Text = "我是一个标签";            //             // button1            //             this.button1.Location = new System.Drawing.Point(48, 103);            this.button1.Name = "button1";            this.button1.Size = new System.Drawing.Size(75, 23);            this.button1.TabIndex = 1;            this.button1.Text = "蓝色";            this.button1.UseVisualStyleBackColor = true;            this.button1.Click += new System.EventHandler(this.button1_Click);            //             // button2            //             this.button2.Location = new System.Drawing.Point(48, 164);            this.button2.Name = "button2";            this.button2.Size = new System.Drawing.Size(75, 23);            this.button2.TabIndex = 2;            this.button2.Text = "黑色";            this.button2.UseVisualStyleBackColor = true;            this.button2.Click += new System.EventHandler(this.button1_Click);            //             // button3            //             this.button3.Location = new System.Drawing.Point(48, 215);            this.button3.Name = "button3";            this.button3.Size = new System.Drawing.Size(75, 23);            this.button3.TabIndex = 3;            this.button3.Text = "退出";            this.button3.UseVisualStyleBackColor = true;            this.button3.Click += new System.EventHandler(this.button3_Click);            //             // Form1            //             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;            this.ClientSize = new System.Drawing.Size(284, 262);            this.Controls.Add(this.button3);            this.Controls.Add(this.button2);            this.Controls.Add(this.button1);            this.Controls.Add(this.label1);            this.Name = "Form1";            this.Text = "Form1";            this.ResumeLayout(false);            this.PerformLayout();        }        #endregion        private System.Windows.Forms.Label label1;        private System.Windows.Forms.Button button1;        private System.Windows.Forms.Button button2;        private System.Windows.Forms.Button button3;    }}

 

转载地址:http://ojrm.baihongyu.com/

你可能感兴趣的文章
MySQL 数据类型和属性
查看>>
mysql 敲错命令 想取消怎么办?
查看>>
Mysql 整形列的字节与存储范围
查看>>
mysql 断电数据损坏,无法启动
查看>>
MySQL 日期时间类型的选择
查看>>
Mysql 时间操作(当天,昨天,7天,30天,半年,全年,季度)
查看>>
MySQL 是如何加锁的?
查看>>
MySQL 是怎样运行的 - InnoDB数据页结构
查看>>
mysql 更新子表_mysql 在update中实现子查询的方式
查看>>
MySQL 有什么优点?
查看>>
mysql 权限整理记录
查看>>
mysql 权限登录问题:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
查看>>
MYSQL 查看最大连接数和修改最大连接数
查看>>
MySQL 查看有哪些表
查看>>
mysql 查看锁_阿里/美团/字节面试官必问的Mysql锁机制,你真的明白吗
查看>>
MySql 查询以逗号分隔的字符串的方法(正则)
查看>>
MySQL 查询优化:提速查询效率的13大秘籍(避免使用SELECT 、分页查询的优化、合理使用连接、子查询的优化)(上)
查看>>
mysql 查询数据库所有表的字段信息
查看>>
【Java基础】什么是面向对象?
查看>>
mysql 查询,正数降序排序,负数升序排序
查看>>