开发者

How to bring a form in the top of desktop?

开发者 https://www.devze.com 2022-12-23 03:07 出处:网络
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.

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

精彩评论

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

关注公众号