I have a gridview in my C# windows application … It allowed to be edited and I want a special cell (named “Price”) to just allow number on keypress … I use the code below for texboxes to just allow numbers … in which event of grid view should I write this code?
private void txtJustNumber_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsDigit((char)(e.KeyChar)) &&
e.KeyChar != ((char)(Keys.Enter)) &&
(e.KeyChar != (char)(Keys.Delete) || e.KeyChar == Char.Parse(".")) &&
e.KeyChar != (char)(Keys.Back))
{
e.Handled = true;
}
}
thx guys … I used below code and my problem resolved …