在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (this.dataGridView1.CurrentCell.ColumnIndex == 4) //指定选择的字段索引 0 1.2.3.4 { TextBox tb = (TextBox)e.Control; //没指定的话就dataGridView1 内 textbox限制 tb.KeyPress += new KeyPressEventHandler(TextBoxDec_KeyPress); } } private void TextBoxDec_KeyPress(object sender, KeyPressEventArgs e) { char key = e.KeyChar; int value = (int)key; if ((value >= 48 && value <= 57) || value == 46 || value == 8 || value == 43 || value == 45) e.Handled = false; else e.Handled = true; } private void TextBoxDec_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar) && e.KeyChar != '.') { e.Handled = true; } }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论