当前位置:网站首页>C mouse event and keyboard event of C (XXVIII)
C mouse event and keyboard event of C (XXVIII)
2022-07-06 03:47:00 【camellias_】
Look at the mouse event today 、 Keyboard events .
1: There are two kinds of mouse events :
EventArgs:MouseEnter/MouseLeave etc.
MouseEventArgs:MouseDoubleClick、MouseDown、MouseUp、MouseHover、MouseMove.
private void button1_MouseEnter(object sender, EventArgs e)
{
label1.Text = " Button entry event ";
}
private void button1_MouseLeave(object sender, EventArgs e)
{
label1.Text = " Button leave event ";
}
private void Form1_MouseDoubleClick(object sender, MouseEventArgs e)
{
label2.Text = " Double click the form event ";
}
private void button2_MouseDown(object sender, MouseEventArgs e)
{
label2.Text = " Press the button 2";
}
private void button2_MouseUp(object sender, MouseEventArgs e)
{
label2.Text = " Release the button 2";
}
private void button2_MouseHover(object sender, EventArgs e)
{
label3.Text = " Mouse on button 2 Stayed on for some time ";
}
private void button2_MouseMove(object sender, MouseEventArgs e)
{
label4.Text = " Mouse on button 2 Go through ";
}
2: Keyboard events
KeyEventArgs:
KeyPressEventArgs:
KeyPress: It can only be used when the focus is on the control .( Press and release to happen )
KeyDown: Occurs when the key is pressed
KeyUp: It happens when you lift the key
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
label1.Text += e.KeyChar;
}
Keyboard events are similar to mouse events , Here are just some concepts , Relevant cases will be added later .
Test using code :
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 mianbanGc
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_MouseEnter(object sender, EventArgs e)
{
label1.Text = " Button entry event ";
}
private void button1_MouseLeave(object sender, EventArgs e)
{
label1.Text = " Button leave event ";
}
private void Form1_MouseDoubleClick(object sender, MouseEventArgs e)
{
label2.Text = " Double click the form event ";
}
private void button2_MouseDown(object sender, MouseEventArgs e)
{
label2.Text = " Press the button 2";
}
private void button2_MouseUp(object sender, MouseEventArgs e)
{
label2.Text = " Release the button 2";
}
private void button2_MouseHover(object sender, EventArgs e)
{
label3.Text = " Mouse on button 2 Stayed on for some time ";
}
private void button2_MouseMove(object sender, MouseEventArgs e)
{
label4.Text = " Mouse on button 2 Go through ";
}
public string str = "";
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
str += e.KeyChar;
label5.Text += e.KeyChar;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label5_Click(object sender, EventArgs e)
{
}
}
}
There are good suggestions , Please enter your comments below .
Welcome to personal blog
https://guanchao.site
Welcome to the applet :

边栏推荐
- mysql关于自增长增长问题
- [practice] mathematics in lottery
- 【Rust 笔记】18-宏
- 登录mysql输入密码时报错,ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO/YES
- 潘多拉 IOT 开发板学习(HAL 库)—— 实验9 PWM输出实验(学习笔记)
- Svg drag point crop image JS effect
- Mathematical modeling regression analysis relationship between variables
- Schnuka: visual positioning system working principle of visual positioning system
- Shell pass parameters
- 2.2 STM32 GPIO operation
猜你喜欢
随机推荐
Cross origin cross domain request
BUAA喜鹊筑巢
Pytorch基础——(1)张量(tensor)的初始化
登录mysql输入密码时报错,ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO/YES
P7735-[noi2021] heavy and heavy edges [tree chain dissection, line segment tree]
[analysis of variance] single factor analysis and multi factor analysis
Svg drag point crop image JS effect
MADDPG的pythorch实现——(1)OpenAI MADDPG环境配置
Pelosi: Congress will soon have legislation against members' stock speculation
2.1 rtthread pin设备详解
How to standardize the deployment of automated testing?
Factors affecting user perception
在 .NET 6 中使用 Startup.cs 更简洁的方法
1、工程新建
Four logs of MySQL server layer
SAP ALV cell level set color
Overview of super-resolution reconstruction of remote sensing images
1.16 - check code
[rust notes] 18 macro
C language -- structs, unions, enumerations, and custom types







