我有一个由 sp 填充的 dgv,一切都是用向导创建的。因为填充大约需要 10 秒,所以我想在后台使用 backgroundworker。我试过:
Public Class frmStart
Delegate Sub updateDGV()
Private Sub frmStart_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
BackgroundWorker1.WorkerSupportsCancellation = True
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, _
ByVal e As System.ComponentModel.DoWorkEventArgs) _
Handles BackgroundWorker1.DoWork
Me.Invoke(New updateDGV(AddressOf UpdatingForm))
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object , _
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) _
Handles BackgroundWorker1.RunWorkerCompleted
msgbox("Completed")
End Sub
Private Sub UpdatingForm()
Try
me.tableadapter.fill(me.dataset.table)
Catch ex As Exception
MsgBox("Error during loading the dgv")
Finally
BackgroundWorker1.CancelAsync()
End Try
End Sub
End Class
我只看到 dgv 中的第一行。如何在后台填充我的整个 dgv,代码中的错误在哪里?此外,我希望在填充过程中看到“请等待您的 dgv 被填充”的弹出窗口。知道如何实现吗?
在我修改代码之前,我只有以下行,它是以编程方式创建的。
me.tableadapter.fill(me.dataset.table)