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

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


目录
相关文章
|
C#
C#中的数组型参数学习笔记
C#中的数组型参数学习笔记
295 1
|
C#
C# WPF 中用代码模拟鼠标和键盘的操作
原文:C# WPF 中用代码模拟鼠标和键盘的操作   原文地址   C#开发者都知道,在Winform开发中,SendKeys类提供的方法是很实用的。
2665 0
halcon联合c#、WPF学习笔记三(dispatcherTimer实时相机显示)
halcon联合c#、WPF学习笔记三(dispatcherTimer实时相机显示)
1258 2
halcon联合c#、WPF学习笔记三(dispatcherTimer实时相机显示)
|
C# C++
halcon联合c#、WPF学习笔记一(WPF配置halcon)
halcon联合c#、WPF学习笔记一(WPF配置halcon)
2361 1
|
测试技术 持续交付 C#
C#程序基础开发入门学习笔记
C#是一种现代的、面向对象的编程语言,广泛应用于Windows应用程序开发、游戏开发(尤其是Unity引擎)、Web应用程序以及跨平台应用等。
557 0
halcon联合c#、WPF学习笔记二(简单案例)
halcon联合c#、WPF学习笔记二(简单案例)
2114 0
|
C# C语言
C#学习笔记22: 面向对象编程入门精讲(下)
C#学习笔记22: 面向对象编程入门精讲
C#学习笔记22: 面向对象编程入门精讲(下)
|
C#
C#鼠标拖拽,移动图片实例
最近工作需要做一个鼠标可以拖拽移动图片的功能。写了几个基本功能,勉强能用。
782 0
C#鼠标拖拽,移动图片实例
c#编程:事件delegate学习笔记-3
c#编程:事件delegate学习笔记-3
316 0