如何生成按键呢? [英] how to generate keypress even?

查看:97
本文介绍了如何生成按键呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void textBox4_KeyPress(object sender, KeyPressEventArgs e)
{
    int ascii = Convert.ToInt16(e.KeyChar);

    if ((ascii >= 97 && ascii <= 122) || (ascii >= 65 && ascii <= 90) || (ascii == 8))
    {

        e.Handled = false;

    }

    else
    {

        e.Handled = true;

    }
}



我写了这段代码,但是如何自动生成这个事件?


I have written this code but how to generate automatically this event?

推荐答案

转到设计师视图并选择TextBox,按F4查看属性窗口

点击事件的ligtning图标

找到你的事件想要添加并双击它。



查看以下屏幕截图

http://stackoverflow.com/questions/1135299/microsoft-visual-studio-and- c-如何在视觉上添加事件到控件 [ ^ ]
go to designer view and select the TextBox, press F4 for property window
click on ligtning icon for events
find the event which you want to add and double click on it.

check below for screen shot
http://stackoverflow.com/questions/1135299/microsoft-visual-studio-and-c-how-to-visually-add-events-to-controls[^]


这篇关于如何生成按键呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆