# Region enter key when the tab key is used
Private void enter_keypress (Object sender, keypresseventargs E)
{
Foreach (control C in this. Controls)
{
C. keypress + = new system. Windows. Forms. keypresseventhandler (sendenter );
}
}
Private void sendenter (Object sender, keypresseventargs E)
{
If (E. keychar = (char) keys. Enter)
{
// Make the buttons take effect
E. Handled = true;
// Send the key command
Sendkeys. Send ("{tab }");
}
}
# Endregion
Use the keychar attribute to sample the keys at run time and modify the keys in a specific runtime environment. For example, you can use keychar to disable non-numeric buttons when entering the zip code, and change all the letter buttons in the data input field to uppercase, you can also monitor the keyboard or other keys and enter the specific keys of the device.
You can obtain or set the following keys:
You cannot obtain or set the following keys:
Tab key.
Insert and delete.
Home.
End.
Page up and page down.
F1-F2.
Alt.
Arrow keys.