How to display message box without any buttons in C#

前端 未结 4 1473
死守一世寂寞
死守一世寂寞 2021-01-13 08:15

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 probl

4条回答
  •  轮回少年
    2021-01-13 08:28

    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.

提交回复
热议问题