문제

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));
            }
도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top