I wroteUsercontrol,Need to handleArrow keys. (Up, down, left, right ).However, these four keys belongDialogkeyThere are two solutions to makeUsercontrolInOnkeydownTo process these four keys.
Solution 1:
Heavy LoadProcessdialogkey.
Protected Override BoolProcessdialogkey (KeysKeydata)
{
If(Keydata =Keys. Up | keydata =Keys. Down
| Keydata =Keys. Left | keydata =Keys. Right)
Return False;
Else
Return Base. Processdialogkey (keydata );
}
Solution 2:
Heavy LoadProcesskeypreview, MandatoryAddKeyMessage event distribution logic; then reloadIsinputkey.
Protected Override BoolProcesskeypreview (RefMessage m)
{
If(Base. Processkeyeventargs (RefM ))
{
Return True;
}
Return Base. Processkeypreview (RefM );
}
Protected Override BoolIsinputkey (Keys keydata)
{
If(This. Focused)
{
Keys keys1 = (keydata & keys. keycode );
Switch(Keys1)
{
CaseKeys. Up:
CaseKeys. down:
CaseKeys. left:
CaseKeys. Right:
{
Return True;
}
}
}
Return Base. Isinputkey (keydata );
}