-4
雖然運行下面的代碼,我得到這個異常:無法轉換到事件處理KeyPressEventHandler
無法隱式轉換System.Eventhandler到 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;
}
}
你想達到什麼目的? – cverb
可能重複的[無法隱式轉換類型'System.EventHandler'爲'System.EventHandler