0

I need to check whether user entered a character or numeric digit in DataGridViewTextBoxCell. How to perform this comparison on the basis of ASCII values of entered key in KeyPress Event of DataGridView. Any Suggestion ?

Itz.Irshad
  • 1,014
  • 5
  • 23
  • 44

2 Answers2

2

There is static functions in the char type:

var isAlpha = char.IsLetter('a');


var isDigit = char.IsNumber('1');

The actual char presses is in the KeyChar property of KeyPressEventArgs.

Felice Pollano
  • 32,832
  • 9
  • 75
  • 115
0

Take a look at the methods available in the char structure http://msdn.microsoft.com/en-us/library/system.char.aspx

another option would be to build a custom control that inherits from DataGridViewTextBoxCell if you need to do this in more than one place.

Jay
  • 2,077
  • 5
  • 24
  • 39