
本文共 3477 字,大约阅读时间需要 11 分钟。
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������
���������������������
������������������������������������������������������������������������������������������������������������������
private void tBox_KeyPress(object sender, KeyPressEventArgs e){ if (e.KeyChar == 0x20) { e.Handled = true; }}
���������������������������������������
private void TextBox_KeyPress(object sender, KeyPressEventArgs e){ if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar)) { e.Handled = true; }}
������������������������������������������������������
private void TextBox_KeyPress(object sender, KeyPressEventArgs e){ if (e.KeyChar != '\b' && !Char.IsDigit(e.KeyChar)) { e.Handled = true; }}
������������������������������������������������
������������������������������������������������������������������0x08���������������������������������������������������������������������������������������������������
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e){ if (e.KeyChar != '\b') { // ������������0-9 if ((e.KeyChar < '0') || (e.KeyChar > '9')) { e.Handled = true; } }}
������������������������������
������������������������������Validating
���������������������������������������������������������������������������������������������������������������������
private void textBox1_Validating(object sender, CancelEventArgs e){ const string pattern = @"^\d+\.?\d+$"; string content = ((TextBox)sender).Text; if (!Regex.IsMatch(content, pattern)) { errorProvider1.SetError((Control)sender, "������������������!"); e.Cancel = true; } else { errorProvider1.SetError((Control)sender, null); }}
���������������������������������������������
������������������������������������������������������������������������������������������
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e){ if (e.KeyChar == '.' && this.textBox1.Text.IndexOf('.') != -1) { e.Handled = true; } // ������0-9������������ if (!((e.KeyChar >= 48 && e.KeyChar <= 57) || e.KeyChar == '.' || e.KeyChar == 8)) { e.Handled = true; }}
������������������������
������������������������������������������������������������������
private void tbx_LsRegCapital_KeyPress(object sender, KeyPressEventArgs e){ if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar)) { e.Handled = true; } else if (Char.IsPunctuation(e.KeyChar)) { // ��������������������������� if (e.KeyChar != '.' || this.textBox1.Text.Length == 0) { e.Handled = true; } // ������������������������������������ if (textBox1.Text.LastIndexOf('.') != -1) { e.Handled = true; } }}
������ASCII������������������
������������������������ASCII���������������������������������������
private void textBox1_KeyPress(object sender, KeyPressEventArgs e){ if ((e.KeyChar <= 48 || e.KeyChar >= 57) && (e.KeyChar != 8) && (e.KeyChar != 46)) { e.Handled = true; }}
���������48
������ ASCII������ 0
���57
������ ASCII������ 9
���8
������������������46
������������������
发表评论
最新留言
关于作者
