Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6337723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:18:18+00:00 2026-05-24T19:18:18+00:00

I want to enable my start button after clicking all the three stop buttons.

  • 0

I want to enable my start button after clicking all the three stop buttons.

I tried to place the button btn4.enabled = false inside the (sender == btn3), but the start button will be enabled if I first clicked on that button.

The three stop buttons can be clicked in random order.

Here’s my code so far:

namespace SlotMachine
{
    class SlotMac
    {
        private Form f;
        Button btn1 = new Button(); // First stop
        Button btn2 = new Button(); // Second stop
        Button btn3 = new Button(); // Third stop
        Button btn4 = new Button(); // Start
        Timer Clock;    // Tick
        Timer Clock1;   // Tick
        Timer Clock2;   // Tick
        Int32 tick = 0;
        Label tb = new Label();
        int[] nNum = new int[3];

        public SlotMac()
        {
            f = new Form();
            f.Text = "Slot Machine";
            //f.Size = new Size(800, 700);
            f.FormBorderStyle = FormBorderStyle.FixedSingle;
        }

        PictureBox[] pics = new PictureBox[7];
        PictureBox[] pics1 = new PictureBox[7];
        PictureBox[] pics2 = new PictureBox[7];
        //PictureBox pb = new PictureBox();

        public void Launch()
        {
            Random r = new Random();
            int i = 0;
            //int x = 0;
            //int x = 50;

            tb.Location = new Point(205,20);
            f.Controls.Add(tb);

            Clock = new Timer();
            Clock.Interval = 800;
            Clock.Tick += new EventHandler(Clock_Tick);

            Clock1 = new Timer();
            Clock1.Interval = 800;
            Clock1.Tick += new EventHandler(Clock1_Tick);

            Clock2 = new Timer();
            Clock2.Interval = 800;
            Clock2.Tick += new EventHandler(Clock2_Tick);

            for (i = 0; i < pics.Length; i++)
            {
                pics[i] = new PictureBox();
                pics[0].Image = Image.FromFile(i + ".jpg");
                pics[i].SetBounds(50, 100, 100, 100);
                //x += 150;
                f.Controls.Add(pics[i]);
            }

            for (i = 0; i < pics1.Length; i++)
            {
                pics1[i] = new PictureBox();
                pics1[i].Image = Image.FromFile(i + ".jpg");
                pics1[i].SetBounds(200, 100, 100, 100);
                //x += 50;
                f.Controls.Add(pics1[i]);
            }

            for (i = 0; i < pics2.Length; i++)
            {
                pics2[i] = new PictureBox();
                pics2[i].Image = Image.FromFile(i + ".jpg");
                pics2[i].SetBounds(350, 100, 100, 100);
                //x += 50;
                f.Controls.Add(pics2[i]);
            }

            f.SetBounds(10, 20, 500, 500);

            // STOP
            btn1.Location = new Point(50, 250);
            btn1.Height = 40;
            btn1.Width = 100;
            f.Controls.Add(btn1);
            btn1.Text = "STOP";
            this.btn1.Click += new EventHandler(this.MyButtonClick);

            // STOP
            btn2.Location = new Point(200, 250);
            btn2.Height = 40;
            btn2.Width = 100;
            btn2.Text = "STOP";
            f.Controls.Add(btn2);
            this.btn2.Click += new EventHandler(this.MyButtonClick);

            // STOP
            btn3.Location = new Point(350, 250);
            btn3.Height = 40;
            btn3.Width = 100;
            btn3.Text = "STOP";
            f.Controls.Add(btn3);
            this.btn3.Click += new EventHandler(this.MyButtonClick);

            // START
            btn4.Location = new Point(200, 370);
            btn4.Height = 40;
            btn4.Width = 100;
            btn4.Text = "START";
            f.Controls.Add(btn4);
            this.btn4.Click += new EventHandler(btn4_Click);
            f.ShowDialog();
        }

        public void Clock_Tick(object sender, EventArgs e)
        {
            tick++;
            Random r = new Random();
            nNum[0] = r.Next(0, 6);
            for (int i = 0; i < pics.Length; i++)
            {
                pics[0].Image = Image.FromFile(nNum[0] + ".jpg");
                pics[1].Image = Image.FromFile(nNum[0] + ".jpg");
                pics[2].Image = Image.FromFile(nNum[0] + ".jpg");
                pics[3].Image = Image.FromFile(nNum[0] + ".jpg");
                pics[4].Image = Image.FromFile(nNum[0] + ".jpg");
                pics[5].Image = Image.FromFile(nNum[0] + ".jpg");
                pics[6].Image = Image.FromFile(nNum[0] + ".jpg");
            }
        }

        public void Clock1_Tick(object sender, EventArgs e)
        {
            tick++;
            Random r = new Random();
            nNum[1] = r.Next(0, 6);
            for (int i = 0; i < pics.Length; i++)
            {
                pics1[0].Image = Image.FromFile(nNum[1] + ".jpg");
                pics1[1].Image = Image.FromFile(nNum[1] + ".jpg");
                pics1[2].Image = Image.FromFile(nNum[1] + ".jpg");
                pics1[3].Image = Image.FromFile(nNum[1] + ".jpg");
                pics1[4].Image = Image.FromFile(nNum[1] + ".jpg");
                pics1[5].Image = Image.FromFile(nNum[1] + ".jpg");
                pics1[6].Image = Image.FromFile(nNum[1] + ".jpg");
            }
        }

        public void Clock2_Tick(object sender, EventArgs e)
        {
            tick++;
            Random r = new Random();
            nNum[2] = r.Next(0, 6);
            for (int i = 0; i < pics.Length; i++)
            {
                pics2[0].Image = Image.FromFile(nNum[2] + ".jpg");
                pics1[1].Image = Image.FromFile(nNum[1] + ".jpg");
                pics1[2].Image = Image.FromFile(nNum[1] + ".jpg");
                pics1[3].Image = Image.FromFile(nNum[1] + ".jpg");
                pics1[4].Image = Image.FromFile(nNum[1] + ".jpg");
                pics1[5].Image = Image.FromFile(nNum[1] + ".jpg");
                pics1[6].Image = Image.FromFile(nNum[1] + ".jpg");
            }
        }

        public void MyButtonClick(object sender, EventArgs e)
        {
            if (sender == btn1)
            {
                Clock.Stop();
            }

            if (sender == btn2)
            {
                Clock1.Stop();
            }

            if (sender == btn3)
            {
                Clock2.Stop();
            }
            Finish();
        }

        public void btn4_Click(object sender, EventArgs e)
        {
            Clock.Start();
            Clock1.Start();
            Clock2.Start();
            btn4.Enabled = false;
        }

        public void Finish()
        {
            if (nNum[0] == nNum[1] && nNum[0] == nNum[2])
            {
                this.tb.Text = "Congratulations!";
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:18:19+00:00Added an answer on May 24, 2026 at 7:18 pm

    You can check if all timers already stopped, like this:

    public void MyButtonClick(object sender, EventArgs e)
    {
    
        if (sender == btn1)
        {
            Clock.Stop();
        }
    
        if (sender == btn2)
        {
            Clock1.Stop();
        }
    
        if (sender == btn3)
        {
            Clock2.Stop();
        }
        Finish();
    
        if(!Clock.Enabled && !Clock1.Enabled && !Clock2.Enabled)
           btn4.Enabled = true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want to enable or disable the button inside a ControlTemplate for a
I have a ASP.Net Menu Control with three levels and flyouts enabled. I want
I want to enable an user to be able to communicate with other users
Using a configuration file I want to enable myself to turn on and off
I'm working on an ASP.NET website which targets desktop browsers. We want to enable
I want 'only' my Login page to be SSL enabled. When the user logsin
I have created a swings application and there is a Start button on the
Hey guys im trying to get a simple button masher up, What i want
If all tables I want to delete from have the column gamer_id can i
-Wall enables a warning I do not want, specifically -Wunknown-pragmas . How to tell

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.