[問題] 文字方塊控制
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
推
11/06 01:41, , 1F
11/06 01:41, 1F
→
11/07 00:32, , 2F
11/07 00:32, 2F
推
11/07 02:45, , 3F
11/07 02:45, 3F
→
11/07 02:46, , 4F
11/07 02:46, 4F
→
11/07 02:48, , 5F
11/07 02:48, 5F