2010-06-08 45 views
-1

喜的朋友即时得到这个错误可以在任何一个plz帮助铸错误 - > System.Windows.Forms.DataGridViewSelectedCellCollection”不包含定义‘演员’

‘System.Windows.Forms.DataGridViewSelectedCellCollection’不包含'Cast'的定义,并且没有找到接受类型为“System.Windows.Forms.DataGridViewSelectedCellCollection”的第一个参数的扩展方法'Cast'(您是否缺少使用指令或程序集引用?)

+1

请张贴一些代码。 – 2010-06-08 07:27:44

回答

2

如果你显示你的代码,它会有所帮助,但它看起来像你正在尝试类似于:

var o = myDataGridView.SelectedCells.Cast(...); 

错误消息告诉你,有没有叫上了selectedCells铸件限定对象,方法,所以你需要看,导致该错误的行并对其进行更改。对于DataGridViewSelectedCellCollection的文档,其中列出了所有可以调用的方法,可以在这里找到:

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewselectedcellcollection_methods(v=VS.100).aspx

您也可能会喜欢阅读的DataGridView.SelectedCells属性的文档:

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.selectedcells.aspx

最后,也许您已经定义了一个名为Cast的扩展方法,该方法对DataGridViewSelectedCellCollection进行操作。例如:

namespace MyLibrary.ExtensionMethods 
{ 
    public static List<Something> Cast(this DataGridViewSelectedCellCollection collection) 
    { 
    var myList = new List<Something>(); 
    // code to cast your collection to something and add it to the list 
    return myList; 
    } 
} 

如果是这样,您需要确保您告诉编译器它可以找到该方法的位置。在C#中使用using指令:

using MyLibrary.ExtensionMethods; 

在VB中它是

Import MyLibrary.ExtensionMethods 
相关问题