MarisP
MarisP

Reputation: 987

Making a new form window appear in c#

I'm trying to make a card game using Windows Application Forms.

The thing is that I don't know how to do the following- for example if i'd have 3 buttons- one of them named, for example, "Play", if i'd click on it, it would open the actual game, but in the same window, it would only make the buttons dissapear, and when i'd click back, it would open the window with buttons again. I don't really know how to explain my problem better, hopefully someone can tell me how to do that.

Upvotes: 1

Views: 116

Answers (3)

Raheel Khan
Raheel Khan

Reputation: 14787

In addition to Leez's answer, in your situation, you should think about using container controls rather than handling the visible states of individual controls.

You could put related controls in a Panel, GroupBox or TabControl and set the visible properties of those containers instead.

Upvotes: 1

Tal Malaki
Tal Malaki

Reputation: 422

You don't have to hide / show the buttons. What you can do instead is to make a new form with the cards on it. That Form will pop up after you click the play button.

private void PlayButton_Click(object sender, EventArgs e)
{
    // You other functionality goes here
    GameForm GF = new GameForm();
    GF.Show();
    //Or - try this and see the difference 
    GF.ShowDialog();
}

Good Luck!

Upvotes: 1

Thilina H
Thilina H

Reputation: 5810

you can use Visible property of button to do that as follows.

    private void button1_Click(object sender, EventArgs e)
    {
        // You other functionality goes here
        button1.Visible = false;
    }

Upvotes: 0

Related Questions