Form.ShowDialog() does not display window with debugging enabled

后端 未结 2 1002
长发绾君心
长发绾君心 2021-02-07 05:21

I\'ve created a test within a Unit Test Project, in which I want pop up a Form using its ShowDialog() function:

[TestMethod]
public void Te         


        
2条回答
  •  日久生厌
    2021-02-07 05:54

    In my case, using VS2017, setting the property ShowInTaskbar as false did the trick.

    This is the complete code used to show the dialog:

    form.TopMost = true;
    form.StartPosition = FormStartPosition.CenterScreen;
    form.ShowInTaskbar = false;
    form.ShowDialog();
    

    P.S. After finding this, I've seen the same solution in Displaying Windows Forms inside unit test methods

提交回复
热议问题