C# 刷新DataGridView
我使用DataTable来定制报表,使用DataView来搜索单个记录 这是我的搜索代码:C# 刷新DataGridView,c#,winforms,datagridview,refresh,C#,Winforms,Datagridview,Refresh,我使用DataTable来定制报表,使用DataView来搜索单个记录 这是我的搜索代码: private void btnSearch_Click(object sender, EventArgs e) { dgvReport.DataSource = new DataView(dt, "StudentID = " + txtSearch.Text, "StudentID", DataViewRowState.CurrentRows); } 现在,我
private void btnSearch_Click(object sender, EventArgs e)
{
dgvReport.DataSource = new DataView(dt, "StudentID = " + txtSearch.Text, "StudentID", DataViewRowState.CurrentRows);
}
现在,我希望在刷新DataGridView时,再次显示所有记录。有什么帮助吗?DataGridView.Refresh()代码似乎不起作用
为什么不将数据源设置回数据表(dt)?刷新将正常工作,它将显示搜索结果
refesh按钮需要将thr报告的数据源设置回dt。刷新方法只会使DGV自身重新绘制。