如何在没有在C#中的任何按钮显示消息框 [英] How to display message box without any buttons in C#

查看:358
本文介绍了如何在没有在C#中的任何按钮显示消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图同时执行的操作显示一条消息给用户。该消息将不会显示任何按钮。 ,只要消息(文本),也许一个背景图像



问题如下:




  • 的MessageBox似乎并不成为很好的控制(因为按钮,它阻止正在运行的进程)。

  • Form.ShowDialog()也阻止正在运行的进程。我不知道该怎么办。

  • 我要显示的信息,运行我的过程,当这个过程完成处理消息。



如何 C#

解决方案

创建一个简单的形式与消息(或公开公共属性,能够改变的消息,或消息参数的构造函数来传递它),并使用的这显示超载。然后禁用(整个)原(所有者)的形式(或只是禁用控制你不想入店)。



所以,在你的主的形式做到这一点

  FORM F =新MessageForm(); 
f.Show(本); //确保我们的车主
this.Enabled = FALSE; //禁用自己
//这里做处理
this.Enabled = TRUE; //我们就大功告成了,让我们
f.Close(); //处置邮件窗体



此外,考虑使用的 BackgroundWorker的


I try to show a MESSAGE to the user while an operation is executed. The MESSAGE won't show any button. Just a MESSAGE (text) and maybe a background image.

The problem is the following:

  • MessageBox does not seem to be the good control (because of button and it blocks the running process).
  • Form.ShowDialog() also blocks the running process. I don't know what to do.
  • I want to show the message, run my process, and dispose the message when the process is done.

How to achieve this in C# ?

解决方案

Create a simple form with the message (or expose a public property to be able to change the message, or a constructor with message parameter to pass it in) and show the form using this Show overload. Then disable the (entire) original (owner) form (or just disable the controls you don't want accesible).

So, in your "main" form do this:

Form f = new MessageForm();
f.Show(this);         //Make sure we're the owner
this.Enabled = false; //Disable ourselves
//Do processing here
this.Enabled = true;  //We're done, enable ourselves
f.Close();            //Dispose message form

Also, consider using a BackgroundWorker.

这篇关于如何在没有在C#中的任何按钮显示消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆