Hiding forms on startup: why doesn't this.Hide() hide my form?

前端 未结 6 1453
有刺的猬
有刺的猬 2020-12-10 02:58

I wanted to hide the main window of my app on startup, so I put this in the constructor:

this.Hide();

This doesn\'t hide my form though. It

6条回答
  •  清歌不尽
    2020-12-10 03:42

    Just override the OnVisibleChanged method and change the visibility of the form in there, something like this:

    protected override void OnVisibleChanged(EventArgs e)
    {
        base.OnVisibleChanged(e);
        this.Visible = false;
    }
    

    And that's it! Simple and clean.

提交回复
热议问题