当前位置:网站首页>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 :
边栏推荐
猜你喜欢
BUAA计算器(表达式计算-表达式树实现)
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
Data analysis Seaborn visualization (for personal use)
Exness foreign exchange: the governor of the Bank of Canada said that the interest rate hike would be more moderate, and the United States and Canada fell slightly to maintain range volatility
BUAA calculator (expression calculation - expression tree implementation)
C#(三十)之C#comboBox ListView treeView
Do you know cookies, sessions, tokens?
遥感图像超分辨重建综述
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)
Yyds dry inventory what is test driven development
【SLAM】lidar-camera外参标定(港大MarsLab)无需二维码标定板
暑期刷题-Day3
3.2 detailed explanation of rtthread serial port device (V2)
遥感图像超分辨率论文推荐
WPF效果第一百九十一篇之框选ListBox
简述C语言中的符号和链接库
Restful style
[meisai] meisai thesis reference template
Ybtoj coloring plan [tree chain dissection, segment tree, tarjan]
Schnuka: what is visual positioning system and how to position it
RT thread -- FTP of LwIP (2)
数据分析——seaborn可视化(笔记自用)
EDCircles: A real-time circle detector with a false detection control 翻译
Crawler of explanation and application of agency theory
Microkernel structure understanding
[prediction model] difference method model
【SLAM】ORB-SLAM3解析——跟踪Track()(3)
On Data Mining