0

我正在使用 BrightIdeasSoftware 的 objectListView 组件,我想展示一个我创建的列表。所以我有两列:标题,艺术家。接下来,我写了一个歌曲类:

class Song
{
    public Song()
    {

    }

    public Song(string title, string artist)
    {
        this.Title = title;
        this.Artist = artist;
    }

    public string Title
    {
        get { return title; }
        set { title = value; }
    }
    private string title;

    public string Artist
    {
        get { return artist; }
        set { artist = value; }
    }
    private string artist;
}

并创建了一个列表:

        List<Song> songs = new List<Song>();
        Song example = new Song("My Immortal", "Evanescence");
        songs.Add(example);

最后,我调用了 SetObjects:

        objectListView1.SetObjects(songs);

但是......问题是该列表作为一个空列表呈现给我!(我的意思是,没有字符串是在运行时编写的......)

有人可以帮我弄清楚为什么...?

4

2 回答 2

0

有什么帮助是输入我想在 AspectName 属性中显示的字段的名称。我的意思是,“标题”/“艺术家”。因为它们保存字符串值,所以我不必输入“AspectToStringFormat”值。

于 2012-03-15T07:26:37.690 回答
0

使用 BrightIdeasSoftware 的 ObjectListView,您可以为将处理显示内容的每一列提供一个委托。

外汇:

var clmTitle = new OLVColumn();

clmTitle.AspectGetter = obj => (obj as Song).Title;


var clmArtist = new OLVColumn();

clmArtist.AspectGetter = obj => (obj as Song).Artist;

objectListView1.Columns.AddRange(new OlVColumn[]{clmTitle,clmArtist});

objectListView1.SetObjects(songs);
于 2014-05-12T10:49:41.743 回答