How to show form in front in C#

后端 未结 11 1949
长发绾君心
长发绾君心 2020-12-06 09:35

Folks,

Please does anyone know how to show a Form from an otherwise invisible application, and have it get the focus (i.e. appear on top of other windows)?

11条回答
  •  眼角桃花
    2020-12-06 09:48

    This is what I use to bring an open form that is part of my application to the front. You can even use it with a button. But the form needs to be open or the application will break.

    "YourOpenForm" has to be the name of your form from the properties window.

        private void button1_Click(object sender, EventArgs e)
        {
            Application.OpenForms["YourOpenForm"].BringToFront();
        }
    

    Good Luck!

提交回复
热议问题