c# - 无法将 IList 转换为绑定(bind)列表

标签 c# winforms bindinglist

我正在开发一个应用程序,我在其中转换 ObjectIList .然后我想将其转换为 BindingList
这是我正在尝试的代码

IList data = spareEntity.getall() as IList;
var listBinding = new BindingList<IList>(data);

public object getall()
{
    using (var worldbankAMSentitiesNew = new WorldBankAMSEntities())
    {
        var q = from fullSpareInventory in worldbankAMSentitiesNew.Spare_Inventory
        select new
        {
            fullSpareInventory.Is_Spare,
            fullSpareInventory.Manufacturer,
            fullSpareInventory.Product_No,
            fullSpareInventory.Remarks,
            fullSpareInventory.Remedy_Ticket_No,
            fullSpareInventory.Serial_No,
            fullSpareInventory.Spare_Type,
            fullSpareInventory.Spare_Inventory_Volume.Spare_Name,
            fullSpareInventory.Spare_ID,
            fullSpareInventory.Assigned_Date,
            fullSpareInventory.Description,
            fullSpareInventory.Spare_Volume_ID
        };
        return q.ToList();
    }
}

最佳答案

您可以尝试如下:-

var yourList = spareEntity.getall() as List<Object>;
var listBinding = new BindingList<Object>(yourList);

关于c# - 无法将 IList 转换为绑定(bind)列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25262784/

相关文章:

c# - 使用 BinarySearch 通过差异查找最接近的索引

c# - 当现有格式不一致时,如何使电话号码变得漂亮/用户友好?

c# - 清除 BindingList 和添加新项目很慢?

c# - 更改两个相关DateTimePicker的值时如何防止堆栈溢出错误?

c# - AllowUserToAddRows 不适用于 DataGridView 上的 List<> 数据源

bindinglist - UltraGrid 添加 BindingList<MyClass> 并将属性名称映射到列名称

c# - 在调试期间在 Visual Studio 中自动附加到子进程

c# - "No target found for method"由 Caliburn Message.Attach() 抛出

c# - 创建动态装配版本,包括日期和随机修订号

c# - 韩国 PC 上的错误缩放