Prevent duplicate MDI children forms

前端 未结 7 748
攒了一身酷
攒了一身酷 2020-12-09 11:47

Is there a way to prevent the opening of a certain form within an MDI container if that said form is already opened?

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 12:07

    This code work for me in C#

          private void btn1_Click(object sender, EventArgs e)
                {
                   Form2 new_form = new Form2();
                    if (new_form.visible)
                        new_form.Show();
                    else
                        new_form.ShowDialog();
                }
    

提交回复
热议问题