CranberryJuice
CranberryJuice

Reputation: 31

C# Forms Event, want button click to produce two buttons

I'm trying to get it so when you click the button (which is START) it brings you two buttons, noob and medium. I can't figure out how to get the second one to show up. The ID is for button1 so I've tried renaming the second to button1 but won't work. How do I pass the button1 again to have it logically produce two buttons from one button?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace App2341
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            button1.Text = "Noob";
            button1.Location = new Point(100, 100);
        }

        private void Button2_Click(object sender, EventArgs e)
        {
            button1.Text = "Medium";
            button1.Location = new Point(100, 150);
        }
        private void Form1_Load(object sender, EventArgs e)
        {



        }
    }
}

Upvotes: 0

Views: 141

Answers (1)

FrozenAssassine
FrozenAssassine

Reputation: 1450

Try to create the three buttons in the designer and give each one a name, then set the visibility of the start-button to visible and the visibility of the other two buttons to hidden. When you click the start button you set the visibility of the startbutton to hidden and the visibility of the other two buttons to visible.

To set the buttons visibility:

button1.Visible = true; //to show the button
button1.Visible = false; //to hide the button

Upvotes: 1

Related Questions