呵呵,你没有清空text
private void txtRight_KeyPress(object sender, KeyPressEventArgs e)
{
string strA = "";
strA = txtRight.Text;
if (strA == "a" || strA == "b" || strA == "c" || strA == "d")
{
string s=strA.ToUpper();
txtRight.Text ="";
txtRight.Text = s;
} }
}
private void txtRight_KeyPress(object sender, KeyPressEventArgs e)
{
string strA = "";
strA = txtRight.Text;
if (strA == "a" || strA == "b" || strA == "c" || strA == "d")
{
string s=strA.ToUpper();
txtRight.Text ="";
txtRight.Text = s;
} }
}
解决方案 »
- 求助:如何用C#监视进程信息并将结果输出到一个文件中
- 求助:通过在面板上单击鼠标使PictureBox上的图片隐藏,然后可以在面板上使用其他控件。
- 请教正则高手,下面这三个是什么意思?
- C#调用COM组件时的结构类型数据封送问题,报PInvoke 签名错误
- datagridview控件中的DataGridViewComboBoxColumn使用时如何获取到下拉选项的SelectedIndex值
- 设定单据为9行,如果记录不够9行,照样画表,但是表内没有记录的水晶报表怎么设计?
- C#方法
- 请问《C#程序设计》中文版电子书的下载地址?
- winform 闪屏问题
- SOS...怎么样获取运行中的其他程序的窗体名称?
- C# MDI子窗体与父窗体互动
- 企业库 Enterprise Library 2.0的问题
string strA = "";
strA = TextBox1.Text;
if (strA == "a" || strA == "b" || strA == "c" || strA == "d")
{
string s=strA.ToUpper();
TextBox1.Text = s;
}
不知道楼主是不是将abcd同时弄进去了,哈哈
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar == 'a' || e.KeyChar == 'b'|| e.KeyChar == 'c' || e.KeyChar == 'd')
{
textBox1.Text = e.KeyChar.ToString().ToUpper();
// textBox1.Text += e.KeyChar.ToString().ToUpper();
}
e.Handled=true;
}
----------------
这是什么意思,学习学习
{
string strA = "";
strA = txtRight.Text;
if (strA == "a" || strA == "b" || strA == "c" || strA == "d")
{
string s=strA.ToUpper();
txtRight.Text.clear;
txtRight.Text = s;
} }
}
txtRight.Text=txtRight.Text.Trim().ToUpper();
=true 原来的按键就不执行了