Search code examples
c#winformsprocessmessagebox

c# message box show then gracefully close after a process?


I currently have a form which I am using. When a user presses export button, it exports some data to an excel worksheet. I have the process happening in the background and it doesn't visually show the user the excel worksheet while writing but does after.

On the c# form, when they click to export, I disable the form so that they cannot press anything on it. I would like there to be a message box or some sort of toast/indication that the excel is writing, and when the excel is finished, the message box/toast/indicator to close and allowing the user to continue.

At the moment the form is disabled, the excel written to, the form is then re-enabled. I have a message box appear using MessageBox.Show("text"); but it isn't really that elegant and looks shoddy.

Has anyone done anything similar and could point me into the right direction.

Thanks, J


Solution

  • You could add something like a StatusBar to the bottom of your form instead of the MessageBox. When the export begins, you can show the information on a label on that statusbar and remove it, when the export finishes. Additionally you can add a progressbar to that statusbar which indicates the status of the export progress.