Displaying a MessageBox on top of all forms, setting location and/or color

后端 未结 7 1303
野性不改
野性不改 2021-01-06 02:03

I have two forms and I set one of the forms\' TopMost property to true. Somewhere, while the program runs, I show a MessageBox, but since TopMost is set to true

7条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-06 02:34

    To show a MessageBox on top of all the other forms of your application (including those with TopMost set) you can use the Show() method overload that takes a parameter of type MessageBoxOptions and pass MessageBoxOptions.ServiceNotification as that parameter.

    DialogResult result = MessageBox.Show("Configuration file was corrupted.\n\nDo you want to reset it to default and lose all configurations?", "Config File Corrupted", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.ServiceNotification);
    

提交回复
热议问题