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

边栏推荐
- Why do you want to start pointer compression?
- 暑期刷题-Day3
- Flask learning and project practice 8: introduction and use of cookies and sessions
- Quartz misfire missed and compensated execution
- Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
- BUAA calculator (expression calculation - expression tree implementation)
- Esbuild & SWC: a new generation of construction tools
- A brief introduction to symbols and link libraries in C language
- Force buckle 1189 Maximum number of "balloons"
- 施努卡:什么是视觉定位系统 视觉系统如何定位
猜你喜欢

Quartz misfire missed and compensated execution

2. GPIO related operations
![[practice] mathematics in lottery](/img/29/2ef2b545d92451cf083ee16e09ffb4.jpg)
[practice] mathematics in lottery

mysql关于自增长增长问题

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

在 .NET 6 中使用 Startup.cs 更简洁的方法

Pointer written test questions ~ approaching Dachang

Blue style mall website footer code

C#(三十)之C#comboBox ListView treeView

多项目编程极简用例
随机推荐
【FPGA教程案例12】基于vivado核的复数乘法器设计与实现
Pytoch foundation - (1) initialization of tensors
three. JS page background animation liquid JS special effect
Schnuka: what is visual positioning system and how to position it
Containerization Foundation
11. Container with the most water
Prime Protocol宣布在Moonbeam上的跨链互连应用程序
Flask learning and project practice 8: introduction and use of cookies and sessions
Restful style
简述C语言中的符号和链接库
[prediction model] difference method model
JVM的手术刀式剖析——一文带你窥探JVM的秘密
Recommended papers on remote sensing image super-resolution
Introduction to DeNO
User experience index system
在 .NET 6 中使用 Startup.cs 更简洁的方法
[analysis of variance] single factor analysis and multi factor analysis
JS Vanke banner rotation chart JS special effect
EDCircles: A real-time circle detector with a false detection control 翻译
Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art