I am attempting to break down user input onto a KeyDown event on a DataGrid by working out whether their input is a letter or a number. This is the method I am using so far;
private void OnDataGridKeyDown(object sender, KeyEventArgs e)
{
if (char.IsLetter(Convert.ToChar(e.Key)))
{
MessageBox.Show("Letter");
}
if (char.IsDigit(Convert.ToChar(e.Key)))
{
MessageBox.Show("Number");
}
}
However, this performs bizzarely. Firstly, the IsDigit never happens and clearly is not working. Secondly the IsLetter works, but only on some letters (W,Z,X,V and Y). There must be a more comprehensive way of doing this as this clearly is not working for me.