How to display a message box in C# as system modal?

前端 未结 5 627
轻奢々
轻奢々 2021-01-20 16:32

How to display a message box in C# as system modal, something like vbModal in Visual Basic 6?

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-20 17:04

    Are you talking about message boxes, or standard forms? If you're talking about standard forms, the easiest .NET equivalent of vbModal is the ShowDialog method of System.Windows.Forms.Form. So, rather than the old

    myForm.Show vbModal
    

    you use

    myForm.ShowDialog();
    

    or

    myForm.ShowDialog(myFormOwner);
    

    This halts execution at the ShowDialog line just like the old vbModal used to.

提交回复
热议问题