C#在事件开始时,启动另一个事件
我想知道是否单击图片以启动按钮单击事件。 但是怎么做呢? ButtonPlus每次命中+1获得,如果达到5/10。。。它会激活其他图像 为了通过点击加号按钮来增加浪费时间,我想点击图像,例如第一个(获取值5)并点击按钮代码 我认为,通过将ButtonPlus值设置为4,并转发到button_click事件,它将得到值5,然后进行切换C#在事件开始时,启动另一个事件,c#,events,C#,Events,我想知道是否单击图片以启动按钮单击事件。 但是怎么做呢? ButtonPlus每次命中+1获得,如果达到5/10。。。它会激活其他图像 为了通过点击加号按钮来增加浪费时间,我想点击图像,例如第一个(获取值5)并点击按钮代码 我认为,通过将ButtonPlus值设置为4,并转发到button_click事件,它将得到值5,然后进行切换 private void button1_Click(object sender, EventArgs e) { if (MaxPunkte
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按钮1\u单击(对象发送者,事件参数e)
{
如果(MaxPunkte>0)
{
如果(按钮1<30)
{
按钮1+=1;
MaxPunkte+=-1;
LabelAnzeige1=按钮按钮1;
label1.Text=LabelAnzeige1.ToString();
label5.Text=MaxPunkte.ToString();
label7.Text=(LabelAnzeige1*10.ToString();
label8.Text=label7.Text;
#区域交换机
开关(按钮1)
{
案例5:
pictureBox1.Image=TraitCalc.Resources.hexagonsall\u 5\u活动;
打破
案例10:
pictureBox2.Image=TraitCalc.Resources.HexagonBig\u 10\u active\u empty;
打破
案例15:
pictureBox3.Image=TraitCalc.Resources.hexagonsall\u 15\u活动;
打破
案例20:
pictureBox4.Image=TraitCalc.Resources.HexagonBig\u 20\u active\u empty;
打破
案例25:
pictureBox5.Image=TraitCalc.Resources.hexagonsall\u 25\u活动;
打破
案例30:
picturebx6.Image=TraitCalc.Resources.HexagonBig\u 30\u active\u empty;
打破
}
#端区
}
}
}
私有无效图片单击(对象发送方,事件参数e)
{
按钮1=4;
//和开始按钮单击事件(添加+1=5->转到切换案例1)
}
- 将按钮单击代码移动到单独的方法中
- 从按钮单击事件调用此方法
- 也可以从图片单击事件调用它
按钮1\u单击。
- 将按钮单击代码移动到单独的方法中
- 从按钮单击事件调用此方法
- 也可以从图片单击事件调用它
(或者你可以像其他方法一样直接调用按钮1\u单击)为什么不直接调用按钮处理程序
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.
}
为什么不直接调用按钮处理程序呢
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.
}