重载构造函数 C#

Overloaded Constructors c#

我里面有 1 个命名空间 (DXApplication5) 和 2 个 classes。我正在尝试使用 class 刷新 gridview。下面这段代码我做错了什么?提前致谢,

Errors:The best overloaded method match for 'DXApplication5.grid_refresh.grid_refresh(DXApplication5.Form1)' has some invalid arguments

Argument 1: cannot convert from 'DevExpress.XtraEditors.XtraForm' to 'DXApplication5.Form1'

public class grid_refresh
{
    public DXApplication5.Form1 frm1;

    public grid_refresh()
    {
        //Default Constructor   
    }

    public grid_refresh(DXApplication5.Form1 frm1)
    {
       frm1.gcStudent.Refresh();
    }        
}

//来自另一个class

 DXApplication5.grid_refresh gr = new grid_refresh(frm1);

问题是您传递的 frm1DevExpress.XtraEditors.XtraForm 的实例,而不是 DXApplication5.Form1

解决方案 1:编写接受 DevExpress.XtraEditors.XtraForm 作为参数的构造函数。

 public grid_refresh(DevExpress.XtraEditors.XtraForm frm1)
 {
       ...
 }  

解决方案 2:使 frm1 成为 DXApplication5.Form1 的实例。