当前位置:网站首页>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 :

边栏推荐
- Data analysis Seaborn visualization (for personal use)
- Mysqldump data backup
- 2.1 rtthread pin device details
- Image super resolution using deep revolutionary networks (srcnn) interpretation and Implementation
- Align items and align content in flex layout
- Force buckle 1189 Maximum number of "balloons"
- JS music online playback plug-in vsplayaudio js
- Pytorch load data
- Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
- Crawler of explanation and application of agency theory
猜你喜欢

Blue style mall website footer code

记录一下逆向任务管理器的过程

自动化测试怎么规范部署?

2.13 weekly report

Ethernet port &arm & MOS &push-pull open drain &up and down &high and low sides &time domain and frequency domain Fourier

3.1 rtthread 串口设备(V1)详解

多项目编程极简用例

Overview of super-resolution reconstruction of remote sensing images
![[Massey] Massey font format and typesetting requirements](/img/27/6b641551d6d8699683972f40f3b8e5.jpg)
[Massey] Massey font format and typesetting requirements

11. Container with the most water
随机推荐
Four logs of MySQL server layer
RT thread -- FTP of LwIP (2)
cookie,session,Token 这些你都知道吗?
Cf603e pastoral oddities [CDQ divide and conquer, revocable and search set]
Suggestions for new engineer team members
[matlab] - draw a five-star red flag
暑期刷题-Day3
Quartz misfire missed and compensated execution
Schnuka: visual positioning system working principle of visual positioning system
[practical exercise] face location model based on skin color
How do we make money in agriculture, rural areas and farmers? 100% for reference
Edcircles: a real time circle detector with a false detection control translation
Record the process of reverse task manager
JS music online playback plug-in vsplayaudio js
SAP ALV cell level set color
Oracle ORA error message
An article will give you a comprehensive understanding of the internal and external components of "computer"
After five years of testing in byte, I was ruthlessly dismissed in July, hoping to wake up my brother who was paddling
[practice] mathematics in lottery
Svg drag point crop image JS effect