I want to pop up a form in C# .net 2.0 which should be in front of the desktop (topmost) until the user clicks the close button.
How to do so?
I tried the code from here: http://dotnet-snippets.de/dns/fenster-wirklich-in-den-vordergrund-des-desktops-brin开发者_JAVA百科gen-SID1005.aspx
But it didn't work. My system is Win7.
Set the form's TopMost property to true and MinimizeBox property to false.
Code below will create MessageBox with TopMost property making it on Top until user clicks No or Yes.
DialogResult result = DialogResult.No;
try {
result = MessageBox.Show(new Form {
TopMost = true, MinimizeBox = false,
}, "some text", "some topic", MessageBoxButtons.YesNo, MessageBoxIcon.Stop);
} finally {
if (result == DialogResult.No) {
}
}
精彩评论