Reputation: 5
I want that the process (when I click on the btnWeiss button) only starts if txbStart_MouseClick got clicked before. So I need an if. But How do I say that:
txbStart_MouseClick == true ? ( if( txbMouseClick ==true) <-- i get an error^^)
My code is below:
private void btnWeiss_Click(object sender, EventArgs e)
{
int summe = 0, z;
lblAnzeige.Text = " ";
while (summe <= 0)
{
z = r.Next(1, 6);
summe = summe + z;
}
lblAnzeige.Text += colors[summe - 1] + "\n";
if (ckbExtrem.Checked == false)
{
lblAnzeige.ForeColor = myColors[Farbe.Next(myColors.Count)];
}
else
{
lblAnzeige.ForeColor = Color.FromArgb(Farbe.Next(256), Farbe.Next(256), Farbe.Next(256));
}
}
private void txbStart_MouseClick(object sender, MouseEventArgs e)
{
int summe = 0, z;
lblAnzeige.Text = " ";
txbStart.Text = " ";
textBox1.Text = " ";
while (summe <= 0)
{
z = r.Next(1, 6);
summe = summe + z;
}
lblAnzeige.Text += colors[summe - 1] + "\n";
if (ckbExtrem.Checked == false)
{
lblAnzeige.ForeColor = myColors[Farbe.Next(myColors.Count)];
}
else
{
lblAnzeige.ForeColor = Color.FromArgb(Farbe.Next(256), Farbe.Next(256), Farbe.Next(256));
}
Upvotes: 0
Views: 112
Reputation: 4658
You could set a bool
when you click the first button and only execute the 2nd button's method when that variable is true.
Upvotes: 1
Reputation: 887245
Events don't have values; it doesn't make any sense to compare them.
It sounds like you want to make a boolean field in your class, and set it to true in the event handler.
You can then check whether the field has been set.
Upvotes: 1