当前位置:网站首页>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 :
边栏推荐
- 在字节做测试5年,7月无情被辞,想给划水的兄弟提个醒
- How to standardize the deployment of automated testing?
- 3.2 detailed explanation of rtthread serial port device (V2)
- [practice] mathematics in lottery
- 如何修改表中的字段约束条件(类型,default, null等)
- Pytoch foundation - (1) initialization of tensors
- Flask learning and project practice 9: WTF form verification
- Do you know cookies, sessions, tokens?
- Schnuka: 3D vision detection application industry machine vision 3D detection
- [001] [stm32] how to download STM32 original factory data
猜你喜欢
cookie,session,Token 这些你都知道吗?
[optimization model] Monte Carlo method of optimization calculation
Teach you to build your own simple BP neural network with pytoch (take iris data set as an example)
多项目编程极简用例
Microkernel structure understanding
C#(二十八)之C#鼠标事件、键盘事件
【SLAM】lidar-camera外参标定(港大MarsLab)无需二维码标定板
Schnuka: 3D vision detection application industry machine vision 3D detection
Svg drag point crop image JS effect
Four logs of MySQL server layer
随机推荐
Blue style mall website footer code
数据分析——seaborn可视化(笔记自用)
给新人工程师组员的建议
Cubemx transplantation punctual atom LCD display routine
Deno介绍
Do you know cookies, sessions, tokens?
mysql关于自增长增长问题
暑期刷题-Day3
BUAA喜鹊筑巢
Differential GPS RTK thousand search
Overview of super-resolution reconstruction of remote sensing images
Pytorch load data
Teach you to build your own simple BP neural network with pytoch (take iris data set as an example)
C#(三十一)之自定义事件
KS003基于JSP和Servlet实现的商城系统
Facebook and other large companies have leaked more than one billion user data, and it is time to pay attention to did
SWC introduction
[slam] orb-slam3 parsing - track () (3)
three. JS page background animation liquid JS special effect
Serial port-rs232-rs485-ttl