我有1个命名空间(DXApplication5)和2个类。我正在尝试用类刷新gridview。我在下面的代码中做错了什么? Thx提前,
错误:最佳重载方法匹配 ' DXApplication5.grid_refresh.grid_refresh(DXApplication5.Form1)'具有 一些无效的论点
参数1:无法转换为' DevExpress.XtraEditors.XtraForm'至 ' DXApplication5.Form1'
public class grid_refresh
{
public DXApplication5.Form1 frm1;
public grid_refresh()
{
//Default Constructor
}
public grid_refresh(DXApplication5.Form1 frm1)
{
frm1.gcStudent.Refresh();
}
}
//从另一个班级打电话
DXApplication5.grid_refresh gr = new grid_refresh(frm1);
答案 0 :(得分:1)
问题在于,您传递的frm1
是DevExpress.XtraEditors.XtraForm
的实例,而不是DXApplication5.Form1
。
解决方案1:编写一个接受DevExpress.XtraEditors.XtraForm
作为参数的构造函数。
public grid_refresh(DevExpress.XtraEditors.XtraForm frm1)
{
...
}
解决方案2:将frm1
设为DXApplication5.Form1
的实例。