private void txtMaxCount_TextChanged(object sender, EventArgs e) { //替换非数字 this.txtMaxCount.Text = Regex.Replace(this.txtMaxCount.Text, @"[^d]*", ""); // 将光标定位到文本框的最后 this.txtMaxCount.SelectionStart = this.txtMaxCount.Text.Length; }
private void txtMaxCount_TextChanged(object sender, EventArgs e) { //替换非数字 this.txtMaxCount.Text = Regex.Replace(this.txtMaxCount.Text, @"[^d]*", ""); // 将光标定位到文本框的最后 this.txtMaxCount.SelectionStart = this.txtMaxCount.Text.Length; }