private void Text_KeyPress(object sender, KeyPressEventArgs e)//处理方法
{
if (!(Char.IsNumber(e.KeyChar)) &&e.KeyChar != (char)8)
{
e.Handled = true;
}
}
private void dgvDevice_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)//显示编辑控件的事件
{
this.dgvDevice.EditingControl.KeyPress += Text_KeyPress;//为当前编辑控件添加事件
}
private void dgvDevice_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
{
this.dgvDevice.EditingControl.KeyPress -= Text_KeyPress;//为当前编辑控件删除事件
}
博客给出了DataGridView控件相关事件处理的代码。包含处理按键输入的Text_KeyPress方法,用于限制输入为数字;dgvDevice_EditingControlShowing方法为编辑控件添加事件;dgvDevice_CellParsing方法为编辑控件删除事件,属于信息技术领域的代码实现。
(只数字和退格键(删除))&spm=1001.2101.3001.5002&articleId=90372238&d=1&t=3&u=7926e66dbb644f40805709104abc3037)
789

被折叠的 条评论
为什么被折叠?



