General data source code refresh, data source code refresh
Create the following method in the program.
# Region refresh the data source
/// <Summary>
/// Refresh the data source
/// </Summary>
/// <Param name = "dgv"> dgv that is needed to refresh </param>
Publicvoid RefreshDataSourceOndgv (DataGridView dgv)
{
If (dgv. DataSource = null)
{
Return;
}
CurrencyManager cmdg = (CurrencyManager) this. BindingContext [dgv. DataSource];
If (cmdg! = Null)
{
Cmdg. Refresh (); // Refresh the data source
}
# Endregion
Assume that the datagridview Instance name is dgvinput.
Bind a data source to dgvinput in the program. For example, this. dgvInput. DataSource = _ inputmouldparts; // The inputmouldparts to be selected is a dataset.
If you want to refresh the control, that is, refresh the data source, add the following code.
RefreshDataSourceOndgv (dgvInput );