Form and Control KeyEvent网站安全分享!


一、Form的KeyEvent KeyCode:

二、Control’s KeyEvent 检测输入control的字符的正确性。


一、Form的KeyEvent

Form and Control KeyEvent

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. }

www.dengb.comtruehttps://www.dengb.com/wzaq/1105054.htmlTechArticleForm and Control KeyEvent 一、Form的KeyEvent KeyCode: private void Form1_KeyDown(object sender, KeyEventArgs e) { if ((e.Modifiers == Keys.Control) (e.KeyCode == Keys.Z)) { this…

—-想了解更多的网站安全相关处理怎么解决关注<计算机技术网(www.ctvol.com)!!>

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/webstt/websy/94796.html

(0)
上一篇 2020年4月25日
下一篇 2020年4月25日

精彩推荐