C# Reading Textbox ignoring characters

后端 未结 2 942
太阳男子
太阳男子 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:58

    Add e.SuppressKeyPress = true; e.Handled = true; to your handler when you want to prevent the key press from going forward.

    As an aside, your if statement is equivalent to if (e.KeyCode == Keys.Return), since it will never be equal to both C and Enter.

提交回复
热议问题