Form and Control KeyEvent

简介: 一、Form的KeyEvent KeyCode: 点击(此处)折叠或打开 private void Form1_KeyDown(object sender, KeyE...

一、Form的KeyEvent

image

KeyCode:


点击(此处)折叠或打开

  1. private void Form1_KeyDown(object sender, KeyEventArgs e)
  2. {
  3.     if ((e.Modifiers == Keys.Control) && (e.KeyCode == Keys.Z))
  4.     {
  5.         this.cancelHandler();
  6.     }
  7.     else if ((e.Modifiers == Keys.Control) && (e.KeyCode == Keys.S))
  8.     {
  9.         this.saveHandler();
  10.     }
  11.     else
  12.         e.Handled = true;
  13. }


二、Control’s KeyEvent

检测输入control的字符的正确性。


点击(此处)折叠或打开

  1. private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  2. {
  3.     if (e.KeyChar == 'b')
  4.         mPwFlag[0] = e.KeyChar;
  5.     if (e.KeyChar == 'a')
  6.         mPwFlag[1] = e.KeyChar;
  7.     if (e.KeyChar == 't')
  8.         mPwFlag[2] = e.KeyChar;
  9.     if (e.KeyChar == '1')
  10.         mPwFlag[0] = e.KeyChar;
  11.     if (e.KeyChar == '2')
  12.         mPwFlag[1] = e.KeyChar;
  13.     if (e.KeyChar == '3')
  14.         mPwFlag[2] = e.KeyChar;

  15.     if (mPwFlag[0] == 'b' && mPwFlag[1] == 'a' && mPwFlag[2] == 't')
  16.     {
  17.         mPwFlag[0] = '0';
  18.         mPwFlag[1] = '0';
  19.         mPwFlag[2] = '0';
  20.         BatCreateTopic bct = new BatCreateTopic(this);
  21.         this.button3.Visible = true;
  22.         bct.ShowDialog(this);
  23.     }
  24. }


相关文章
|
XML JSON 数据处理
postman 中 body的form-data,x-www-form-urlencoded,raw,binary含义
postman 中 body的form-data,x-www-form-urlencoded,raw,binary含义
529 0
postman 中 body的form-data,x-www-form-urlencoded,raw,binary含义
head 插件 Content-Type header [application/x-www-form-urlencoded] is not supported
head 插件 Content-Type header [application/x-www-form-urlencoded] is not supported
138 1
|
7月前
使用Form报错提示If ngModel is used within a form tag, either the name attribute must be set or the form
使用Form报错提示If ngModel is used within a form tag, either the name attribute must be set or the form
|
JSON 数据格式
axios.post请求出错:Request header field content-type is not allowed by Access-Control-Allow-Headers in……
axios.post请求出错:Request header field content-type is not allowed by Access-Control-Allow-Headers in……
|
前端开发 JavaScript
ajax请求的重定向处理--Request header field x-requested-with is not allowed by Access-Control-Allow-Header
ajax请求的重定向处理--Request header field x-requested-with is not allowed by Access-Control-Allow-Header
506 0
|
开发框架 前端开发 .NET