0

I am doing the upload to and download from azure blob storage from a windows forms application.

In both the cases, when user clicks upload/download button, i want a message "Configuration being uploaded/downloaded.please wait.." to pop up and this messagebox should automatically close by itself when the upload/download is finished

Then another messagebox with message "Upload/Download completed" should pop up.

I am unable to close the messagebox. is there any way to do this without user interaction? Also i don't need the OK button on the MessageBox.

I could go with a progress bar with percentage, but i don't want the progress bar for this particular case.

I am trying to work with the code below:

internal partial class CustomMessageForm : Form
    {
        public CustomMessageForm(string content)
        {
            MessageBox.Show(content);
        }

       // public void ShowBox(string content)
       //{
            //MessageBox.Show(content);
        //}
    }

    /// <summary>
    /// Your custom message box helper.
    /// </summary>
    public static class CustomMessageBox
    {
        public static void Show(string content)
        {
            // using construct ensures the resources are freed when form is closed
            using (var form = new CustomMessageForm(content))
            {
                form.ShowDialog();
            }
        }
    }

The idea is to instantiate this form and call the show method to pop up the message when the upload starts. when the upload is finished i want to close this form.

The message box has close button, which requires the user to give the input. i don't need the close button and should be able to close the form when upload is completed using form.close() method.

Harshith R
  • 418
  • 1
  • 11
  • 31
  • 2
    I'd suggest writing your own form, and have it provide whatever features you require (rather than using `MessageBox`). – mjwills Sep 04 '19 at 05:40
  • Custom Message box will do the thing. And things will be even easier if you don't need `DialogResult` back from the messagebox – Amit Sep 04 '19 at 06:05
  • As mentioned you can use custom form. Have a look at this thread: https://stackoverflow.com/questions/11502338/how-to-display-message-box-without-any-buttons-in-c-sharp – mitch Sep 04 '19 at 06:50
  • Clearly you do not want to use MessageBox, use StatusStrip instead. – Hans Passant Sep 04 '19 at 08:34
  • Don't use `MessageBox.Show`. – mjwills Sep 04 '19 at 11:23
  • 1
    This has been asked before, there seem to be lots of possible solutions here - https://stackoverflow.com/questions/14522540/close-a-messagebox-after-several-seconds/14522902#14522902 – ZedLepplin Sep 04 '19 at 12:42

0 Answers0