How do I show a “Loading . . . please wait” message in Winforms for a long loading form?

前端 未结 12 616
一生所求
一生所求 2020-12-04 17:29

I have a form that is very slow because there are many controls placed on the form.

As a result the form takes a long time to loaded.

How do I load the fo

12条回答
  •  攒了一身酷
    2020-12-04 18:32

    Another way of making "Loading screen" only display at certain time is, put it before the event and dismiss it after event finished doing it's job.

    For example: you want to display a loading form for an event of saving result as MS Excel file and dismiss it after finished processing, do as follows:

    LoadingWindow loadingWindow = new LoadingWindow();
    
    try
    {
        loadingWindow.Show();                
        this.exportToExcelfile();
        loadingWindow.Close();
    }
    catch (Exception ex)
    {
        MessageBox.Show("Exception EXPORT: " + ex.Message);
    }
    

    Or you can put loadingWindow.Close() inside finally block.

提交回复
热议问题