Whilst running the below code, I get this exception:
Cannot implicitly convert System.Eventhandler to System.Window.Form.KeyPressEventHandler
private void grdPOItems_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
int colIndex = grdPOItems.CurrentCell.ColumnIndex;
string colName = grdPOItems.Columns[colIndex].Name;
if(colName == "Qty" || colName == "Rate")
{
e.Control.KeyPress += new EventHandler(CheckKey);
}
}
private void CheckKey(object sender, EventArgs e)
{
if (((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar!='.'))
{
e.Handled = true;
}
}