Click here to Skip to main content
15,886,797 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more: , +
C#
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?
Posted

1 solution

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[^]
 
Share this answer
 
v2
Comments
Abhinav Chaudhary 14-May-14 0:20am    
Thank you Sir!
DamithSL 14-May-14 0:23am    
You're welcome :D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900