Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have actually one classic Windows form and one button. I have this code

    private void Form1_Load(object sender, EventArgs e)
    {
        this.Hide();
        this.Visible = false;
    }

    private void button1_Click(object sender, EventArgs e)
    {
        this.Hide();
    }

I would like to know why isn't form hidden just after it is being loaded but works when I click on that button? Can somebody explain it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
553 views
Welcome To Ask or Share your Answers For Others

1 Answer

The Load event fires before the form is actually visible. Try using the Form.Shown event. This will fire when the form is actually painted on-screen.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...