我有一个绑定到数据集的数据网格视图控件。因此,当使用新记录更新数据集时,它将显示在网格中。问题是,我必须最小化窗口或强制重新绘制该窗口以查看更新的网格。
有关如何调用刷新的任何想法? Form.refresh和form.grid.refresh不起作用。
答案 0 :(得分:0)
回应我的评论....这很快在编辑器中打印出来并没有经过测试,但是应该让你知道应该怎么做。
Public Class Form1
Dim ds as New DataSet
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Initial load of the DataSet
LoadGridView()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Update the DataSet
'Then reload the GridView
ReloadGridView()
End Sub
Private Sub LoadGridView()
ds = 'Fetch the data from the DB and lod into DataSet.
'Bind DataSet to GridView.
DataGridView1.DataSource = ds.Tables(0)
End Sub
Private Sub ReloadGridView()
DataGridView1.DataSource = Nothing
LoadGridView()
End Sub
End Class