2

我里面有 1 个命名空间(DXApplication5)和 2 个类。我正在尝试用一个类刷新gridview。我在下面的代码中做错了什么?提前谢谢,

错误:“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);
4

1 回答 1

1

问题是frm1你传递的是一个实例DevExpress.XtraEditors.XtraForm,而不是DXApplication5.Form1

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

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

解决方案 2:使其frm1成为DXApplication5.Form1.

于 2015-12-25T20:15:11.927 回答