Exception when adding list to ObjectListView

删除回忆录丶 提交于 2019-12-11 03:46:32

问题


I just started with ObjectListView, and I am trying to replace the ListView I used before in my application. I managed to build a list using the following type I made:

public class Record
{
    public bool IsActive = true;

    public Record(string barcode, string info, string desc)
    {
        this.barcode = barcode;
        this.info = info;
        this.desc = desc;
    }

    private string Barcode
    {
        get { return barcode; }
        set { barcode = value; }
    }

    private string barcode;

    private string Info
    {
        get { return info; }
        set { info = value; }
    }

    private string info;

    private string Desc
    {
        get { return desc; }
        set { desc = value; }
    }

    private string desc;
}

This seems to work so far and I managed to populate a list of this type with 830 entries.

When I try to fill the OLV with this list using OLV.SetObjects(list), however, OLV freaks out and spams the following exception in the debug output, never ending:

A first chance exception of type 'BrightIdeasSoftware.MungerException' occurred in ObjectListView.dll

I can't seem to retrieve more information on this exception, unfortunately, and google isn't really telling me anything either.

The columns I use in my OLV have the aspectnames "barcode", "info" and "desc". I hope this is the right way to use OLV, as I find the documentation rather confusing and have a hard time understanding it at all - the demo project isn't much help either.

Why is this exception thrown, how can I prevent it and am I doing this OLV thing correctly?


回答1:


Answer: The properties are set to private, and they should've been public. Once I switched that around, all was well.

Credit goes to drch on the C# chat for this amazing answer.



来源:https://stackoverflow.com/questions/17107791/exception-when-adding-list-to-objectlistview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!