委托类型无法转换匿名方法

Nis*_*sar 1 c# winforms

在以下行"this.dgvReport.Invoke(delegate")中收到错误

"无法将匿名方法转换为'System.Delegate'类型,因为它不是委托类型"

    public void FillProductGrid()
    {
        ProductSP productSP = new ProductSP();
        DataTable dtbl = new DataTable();
        string productname = "";
        dtbl = productSP.StockReport(productname, this.cbxPrint.Checked);
        this.dgvReport.Invoke(delegate
        {
            this.dgvReport.DataSource = dtbl;
        });
    }
Run Code Online (Sandbox Code Playgroud)

Ser*_*kiy 8

只需将转换添加到具有相同签名的某个委托类型:

this.dgvReport.Invoke((MethodInvoker)(delegate {
        this.dgvReport.DataSource = dtbl;
}));
Run Code Online (Sandbox Code Playgroud)