我想在textbox的keypress事件中捕获用户输入的按键,如果是小写字母,就转成大写字母,我本来想直接给e.KeyChar覆值,可是e.KeyChar是只读的,请问该怎么做?private void textBox2_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) {
char c = e.KeyChar.ToString().ToUpper().ToCharArray()[0];
e.KeyChar = c; // e.KeyChar is readonly.
}
char c = e.KeyChar.ToString().ToUpper().ToCharArray()[0];
e.KeyChar = c; // e.KeyChar is readonly.
}
private void txtYearLimit_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if(Char.IsLower(e.KeyChar))
{
char upperChar = Char.ToUpper(e.KeyChar);
this.txtRe.text = this.txtRe.text + upperChar.ToString();
e.Handled=true;
}
}