我想要如果单击图片以启动按钮单击事件。 但是怎么办? ButtonPlus 通过每次点击 +1 获得 yield ,如果达到 5/10... 它会激活另一个图像。
为了通过点击加号按钮来增加浪费时间,我想点击图像,例如第一个(获取值 5)并执行 button_click 代码。
我想通过将 ButtonPlus 值设置为 4,然后转发到 button_click 事件,它获得值 5,然后进行切换。
private void button1_Click(object sender, EventArgs e)
{
if (MaxPunkte > 0)
{
if (ButtonPlus1 < 30)
{
ButtonPlus1 += 1;
MaxPunkte += -1;
LabelAnzeige1 = ButtonPlus1;
label1.Text = LabelAnzeige1.ToString();
label5.Text = MaxPunkte.ToString();
label7.Text = (LabelAnzeige1 * 10).ToString();
label8.Text = label7.Text;
#region Switch
switch (ButtonPlus1)
{
case 5:
pictureBox1.Image = TraitCalc.Resources.HexagonSmall_5_active;
break;
case 10:
pictureBox2.Image = TraitCalc.Resources.HexagonBig_10_active_empty;
break;
case 15:
pictureBox3.Image = TraitCalc.Resources.HexagonSmall_15_active;
break;
case 20:
pictureBox4.Image = TraitCalc.Resources.HexagonBig_20_active_empty;
break;
case 25:
pictureBox5.Image = TraitCalc.Resources.HexagonSmall_25_active;
break;
case 30:
pictureBox6.Image = TraitCalc.Resources.HexagonBig_30_active_empty;
break;
}
#endregion
}
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{
ButtonPlus1 = 4;
//and start button click event (adds +1 = 5 -> go to switch case 1)
}
请您参考如下方法:
为什么不直接调用按钮处理程序?
private void pictureBox1_Click(object sender, EventArgs e)
{
ButtonPlus1 = 4;
//and start button click event (adds +1 = 5 -> go to switch case 1)
button1_Click(null, null); // or whatever arguments you need,
// but you were not using them.
}
