我用了9,但是不对啊!就是不知道原因,我用的是KeyPress
if(e.KeyChar==(char)9)
{
if(textBox2.Text.Trim()=="")
{
MessageBox.Show("请填写数量!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
textBox2.Focus();
return;
}
if(textBox3.Text.Trim()=="")
{
textBox3.Text="0";
}
textBox4.Text=Convert.ToString(Convert.ToDecimal(textBox2.Text)*Convert.ToDecimal(textBox3.Text));
}
这里写上9就没有用啊!我想知道为什么?还是我的事件关联错了?
if(e.KeyChar==(char)9)
{
if(textBox2.Text.Trim()=="")
{
MessageBox.Show("请填写数量!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
textBox2.Focus();
return;
}
if(textBox3.Text.Trim()=="")
{
textBox3.Text="0";
}
textBox4.Text=Convert.ToString(Convert.ToDecimal(textBox2.Text)*Convert.ToDecimal(textBox3.Text));
}
这里写上9就没有用啊!我想知道为什么?还是我的事件关联错了?
如果你想在TextBos按下Tab触发事件,在Leave或LostFocus事件下写代码试试.
{
MessageBox.Show(e.KeyValue.ToString(),"看看是多少?");//按下一个按钮.对话框里显示的就是这个剪的值
//判断按下的按钮值,if(e.KeyValue==27)
{
this.Width=520;
this.Height=428;
}
}
if ((e.KeyCode == Keys.Tab)&&(e.Control==true))
{
if(textBox2.Text.Trim()=="")
{
MessageBox.Show("请填写数量!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
textBox2.Focus();
return;
}
if(textBox3.Text.Trim()=="")
{
textBox3.Text="0";
}
textBox4.Text=Convert.ToString(Convert.ToDecimal(textBox2.Text)*Convert.ToDecimal(textBox3.Text));
}