private void dgvObjectiveQuestion_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
TextBox tb = null;
if (dgvObjectiveQuestion.SelectedCells.Count > 0)
{
//DataGridViewCell cell = dgvObjectiveQuestion.SelectedCells[0];
tb = (TextBox)e.Control; //赋值
tb.KeyPress += Cells_KeyPress; //绑定到事件KeyPress
}
else
{
if (tb != null)
{
tb.KeyPress -= Cells_KeyPress;
}
}
}
private void Cells_KeyPress(object sender, KeyPressEventArgs e)
{
e.KeyChar = Char.ToUpper(e.KeyChar);
GlobalFunctionHelper.KeyPressCharCheck(e);
}
{
TextBox tb = null;
if (dgvObjectiveQuestion.SelectedCells.Count > 0)
{
//DataGridViewCell cell = dgvObjectiveQuestion.SelectedCells[0];
tb = (TextBox)e.Control; //赋值
tb.KeyPress += Cells_KeyPress; //绑定到事件KeyPress
}
else
{
if (tb != null)
{
tb.KeyPress -= Cells_KeyPress;
}
}
}
private void Cells_KeyPress(object sender, KeyPressEventArgs e)
{
e.KeyChar = Char.ToUpper(e.KeyChar);
GlobalFunctionHelper.KeyPressCharCheck(e);
}