KeyDown event - how to easily know if the key pressed is numeric?

后端 未结 8 1896
天命终不由人
天命终不由人 2020-12-19 03:00

I am currently handling the KeyDown event of a DataGridView control. One of the columns is filled by calculated values and I want the user to be able to override the cell va

8条回答
  •  猫巷女王i
    2020-12-19 03:39

    A bit more condensed version:

        private void KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = !Char.IsDigit(e.KeyChar); // only allow a user to enter numbers
        }
    

提交回复
热议问题