Question

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));
            }
Was it helpful?

Solution

You could set a bool when you click the first button and only execute the 2nd button's method when that variable is true.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top