开发者

Object to List<Song>

开发者 https://www.devze.com 2022-12-09 09:48 出处:网络
I am currently using ObjectListView, and right now, i\'m trying to get it so if i click on a开发者_JAVA技巧n object (row), it will give me information about that song (in list form).

I am currently using ObjectListView, and right now, i'm trying to get it so if i click on a开发者_JAVA技巧n object (row), it will give me information about that song (in list form).

Currently, I have a custom list:

public Song(string title, string artist, string album, string genre, string time, int playcount, string location)
        {
            this.Title = title;
            this.Artist = artist;
            this.Album = album;
            this.Genre = genre;
            this.Time = Convert_Time(Convert.ToInt32(time));
            this.PlayCount = playcount;
            this.Location = Convert_Location(location) ;
        }

I want to be able to convert an object into that list form.

private void olvMain_SelectedIndexChanged(object sender, EventArgs e)
    {
        object thing = olvMain.GetItem(olvMain.SelectedIndex).RowObject;        
    }

Currently it returns Genesis.Song, which happens to contain all the data of the selected song. However, I can't access the information in object form. Is there anyway way to convert/ extract it?


Just a guess, but are you able to simply cast the object to your Song type?

private void olvMain_SelectedIndexChanged(object sender, EventArgs e)
{
    Song thing = (Song)olvMain.GetItem(olvMain.SelectedIndex).RowObject;
}


Does

Song thing = (Song)olvMain.GetItem(olvMain.SelectedIndex).RowObject

work?

0

精彩评论

暂无评论...
验证码 换一张
取 消