方法许多
正直表达式:"^[a-zA-Z0-9]+$" 这里不详细解答
自己用的方法是:
private void datagridview1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs
e)
{
TextBox innerTextBox;
if (e.Control is TextBox &&
datagridview1.CurrentCell.ColumnIndex==1) {
innerTextBox = e.Control as TextBox;
innerTextBox.KeyPress +=new KeyPressEventHandler(innerTextBox_KeyPress);
}
}
private void innerTextBox_KeyPress(object sender, KeyPressEventArgs e) {
if (e.KeyChar != 8 && !char.IsNumber(e.KeyChar) && !char.IsLower(e.KeyChar) && !char.IsUpper(e.KeyChar))
{
e.Handled = true;
}
}

1331

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



