Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Help with c# app for beginner please

Mike_1

Coder
Hi all,

I am trying to build a desktop app for my own personal use. I am a total beginner at coding but have learnt how to get button click to show image in picturebox, and a few other things.
What I need help with at the moment is how to get an image to show after clicking consecutive buttons, i.e click button1 then 2 then 3, and only after clicking all buttons in that order image shows in picture box.
Thank you in advance for any help at all with this🙂
 
I thought I'd try and work this one out. I'm not an expert but this code seems to work.
C#:
namespace csharptest
{

    public partial class Form1 : Form
    {
    int buttonsequence = 0;

        public Form1()
        {
        InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
        buttonsequence = 1;
        MessageBox.Show("Button1 pressed.");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (buttonsequence == 1)
            {
            buttonsequence = 2;
            MessageBox.Show("Button1 pressed and then Button2 pressed.");
            }
            else
            buttonsequence = 0;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (buttonsequence == 2)
            {
            MessageBox.Show ("Show the image!");
            buttonsequence = 0;
            }
            else
            buttonsequence = 0;
        }
    }
}
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom