tags:

views:

59

answers:

2

I am currently using ObjectListView, and right now, i'm trying to get it so if i click on an 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?

+4  A: 

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;
}
LukeH
yes...i can't believe i forgot about that :/ tysm :P
Mike
+1  A: 

Does

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

work?

Mike Burton