填充数据表时显示 'Retrieving Data' 消息

Show 'Retrieving Data' Message while filling the Datatable

我想在填充数据表时像 'Retrieving Data' 一样在数据网格上显示消息。有机会实现吗?

这是我填充数据表的代码;

public void getAlertGrid()

    {
            odaAlert = new OracleDataAdapter(getAlert, oradb); //odaAlert is Adapter
            odaAlert.Fill(dtAlert);  // dtAlert is Datatable
            ugAlert.DataSource = dtAlert;
    }

正如@IkramTurgunbaev 所说,您需要异步加载数据并更新状态栏。在调用 getAlertGrid 方法的地方执行如下操作:

private void MethodThatCallsGetAlertGrid()
{
    // Show the progress bar and set the style of progress bar to Marquee. This will show continiously scrolling block across progress bar, as you cannot know the current progress percent
    this.progressBar1.Visible = true;
    this.progressBar1.Style = ProgressBarStyle.Marquee;

    // Start loading the data source async
    Task.Factory.StartNew(() =>
        this.getAlertGrid())
   .ContinueWith((antecedent) =>
    {
        // Set data source on UI thread. Remove the same row from your getAlertGrid method
        ugAlert.DataSource = dtAlert;

        // Hide the progress bar
        this.progressBar1.Visible = false;
    }, TaskScheduler.FromCurrentSynchronizationContext());