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

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

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 + ")";
        }
    }
}


上一篇:大数据计算引擎,为什么阿里坚定地选择 Flink?| 直播预告


下一篇:云数据库的连接