C#学习笔记(8)鼠标键盘事件处理

来源:互联网 发布:新歌2014网络红歌 编辑:程序博客网 时间:2024/06/05 00:13

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 demo9{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private void Form1_KeyDown(object sender, KeyEventArgs e)        {            MessageBox.Show("按动的键为:" + e.KeyCode.ToString());        }        private void Form1_MouseDown(object sender, MouseEventArgs e)        {            //响应鼠标的不同按键             if (e.Button == MouseButtons.Left)            { MessageBox.Show("按动鼠标左键!"); }            if (e.Button == MouseButtons.Middle)            { MessageBox.Show("按动鼠标中键!"); }            if (e.Button == MouseButtons.Right)            { MessageBox.Show("按动鼠标右键!"); }        }        private void Form1_MouseMove(object sender, MouseEventArgs e)        {            this.Text = "当前鼠标的位置为:( " + e.X + " , " + e.Y + ")";        }    }}


0 0