开发者

How to bring a form in the top of desktop?

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) {

            }
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜