Winform--使用BindingSource作为datagridview的数据源

如题。

使用方法简写:

private List<SaleProductInfo> saleProductList = new List<SaleProductInfo>();
private BindingSource bs = new BindingSource();

public FrmSaleManage()
{
      InitializeComponent();

      this.dgvProdutList.AutoGenerateColumns = false;
}

private void Funcation()
{
       //数据绑定
       this.bs.DataSource = this.saleProductList;
       this.dgvProdutList.DataSource = null;
       this.dgvProdutList.DataSource = this.bs;
}

BindingSource提供的方法:

this.bs.MoveLast();//dgv聚焦到最后一行
原文地址:https://www.cnblogs.com/EasonDongH/p/8056072.html