匹配委托“系统.操作”没有重载
本文关键字:重载 操作 系统 | 更新日期: 2023-09-27 18:35:32
public void UpdateDataGrid(bool newInsert = false)
{
//ThreadSafe (updating datagridview from AddEventForm is not allowed otherwise
if (InvokeRequired)
{
Invoke(new Action(UpdateDataGrid));
}
else
{
Util.PopulateDataGridView(ref this.EventsDataGridView,newInsert);
}
}
我不知道如何为新的 Action() 提供可选参数。
我尝试了新的操作(更新数据网格),但仍然抛出运行时错误。
谢谢
您需要创建一个方法委托来封装方法的调用,传递最初指定的参数,如下所示:
() => UpdateDataGrid(newInsert)
在上下文中:
public void UpdateDataGrid(bool newInsert = false)
{
//ThreadSafe (updating datagridview from AddEventForm is not allowed otherwise
if (InvokeRequired)
{
Invoke(new Action(() => UpdateDataGrid(newInsert)));
}
else
{
Util.PopulateDataGridView(ref this.EventsDataGridView,newInsert);
}
}