C# Reading Textbox ignoring characters

后端 未结 2 946
太阳男子
太阳男子 2021-01-26 03:37

Hi everyone i have a key down event as follows

if (e.KeyCode == Keys.C && e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
{
    var amount = textBo         


        
2条回答
  •  一向
    一向 (楼主)
    2021-01-26 03:56

    A while back I wrote a short post about restricting user input into TextBoxes, which is available here (Restricting allowed characters in TextBox) but one thing that I realised that it didn't handle was users pasting text that contains those characters into the TextBox for that the following may be of use to you (Stopping someone from pasting into a TextBox). Both of the posts were written in VB.NET but the code is simple enough that you shouldn't have any issues moving the code over to C#.

    Hope this helps :)

提交回复
热议问题