作者ckkt (!@#$)
看板C_Sharp
标题[问题] 文字方块控制
时间Thu Nov 5 21:40:33 2009
namespace box
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Text = "sell drinks";
this.BackColor = Color.Yellow;
label1.Text = "name";
label2.Text = "how much";
label3.Text = "how many";
label4.Text = "total money";
button1.Text = "蝣筝꺚";
button2.Text = "皜雎妚";
textBox1.BackColor = Color.Yellow;
textBox1.Text = "cola";
textBox1.ReadOnly = true;
textBox2.BackColor = Color.Yellow;
textBox2.Text = "25";
textBox2.ReadOnly = true;
textBox4.BackColor = Color.Yellow;
textBox4.ReadOnly = true;
}
private void button1_Click(object sender, EventArgs e)
{
if (??)
{
textBox3.Focus();
}
else
{
int a = int.Parse(textBox3.Text) * int.Parse(textBox2.Text);
textBox4.Text = a.ToString();
}
}
private void button2_Click(object sender, EventArgs e)
{
textBox3.Clear();
textBox4.Clear();
textBox3.Focus();
}
}
}
请问??里要怎麽设
才有办法让我在按了button1後
可以执行textBox3.Focus();
因为如果textBox3里我没有打任何数字
就去按button1就会当掉
还是有其他方法可以让textBox3不输入任何数字时
按button1也不会当机的
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 122.125.196.27
1F:推 wesley412:(?)..fill textBox3.text=="" try it!! 11/06 01:41
2F:→ leo60037:在可能产生例外的地方加入 try catch 11/07 00:32
3F:推 iamso1:if (textBox3.Text ==String.Empty) 11/07 02:45
4F:→ iamso1:就是说 如果你的textbox3.text是空白的话 11/07 02:46
5F:→ iamso1:呜..刚刚看到才发现我跟一楼是同样意思 11/07 02:48