Check if Keys is Letter/Digit/Special Symbol

后端 未结 6 2050
时光取名叫无心
时光取名叫无心 2021-01-02 18:45

I override ProcessCmdKey and when I get Keys argument, I want to check if this Keys is Letter or Digit or Special Symbol.

I ha

6条回答
  •  一向
    一向 (楼主)
    2021-01-02 18:53

    you need either a giant switch/case statement or check for ranges. You may find it easier to check for the keys you want to exclude, depending on which there is fewer of. Look at this for all the possible values. http://msdn.microsoft.com/en-us/library/system.windows.forms.keys.aspx

    if (keyData >= Keys.A && keyData <= Keys.Z)
       // do something
    

    or

    switch(keyData) {
    case Keys.Add:
    case Keys.Multiply:
    // etc.
       // do something
       break;
    }
    

提交回复
热议问题