more listview questions

adding instances of classes(see code)

Page 1 of 1

0 Replies - 609 Views - Last Post: 18 November 2009 - 10:54 AM Rate Topic: -----

#1 Choscura   User is offline

  • D.I.C Lover


Reputation: 478
  • View blog
  • Posts: 2,267
  • Joined: 18-October 08

more listview questions

Post icon  Posted 18 November 2009 - 10:54 AM

Hey everyone, back again with more questions about listview stuff.

basically, I'm trying to make my own version of iTunes. here's a quick hash of the important bits of code so you have an idea of what I'm doing. I know it's technically bad coding to use all public members, but I'm just doing it here so that it's easy to read (and so I have less to type).

public partial class Form1: Form
{

public list<media> filelibrary= new list<media>();

public Form1()
{
IntializeComponent();
listView1.View=View.Details;
}

//
//here's the bit I'm having trouble with
//
public void media_adder
{
//inside this void function is pseudo code of what I think this should 
//kind of look like, but I'm not sure how to make it work:
listView1.Items.Clear();

foreach(media in filelibrary)
{
   listViewItem temp= new listViewItem();
  temp.subitems.addrange{
	foreach(media.data in media.metadata)
	{
//another problem area: how to match the name of the value of the 
//data (eg, "director's name") to the column's header text?
		if(media.metadata.data.name== listView1.Columns.text)
		return media.metadata.data.value;
		else
		return "";
	}

}

}

public class data{  public string name, value;}

public class media{

public list<data> metadata;
//somewhat flexible way of storing different attributes.  for example, 
//the user could store some movies according to who directed them, 
//but not all videos are directed- eg, pretty much all of youtube- and 
//so I want to make this as free-form as possible

public string filepath;//location on drive of the media

public int hitcount; //number of times a song/movie/etc is played
}


}



Is This A Good Question/Topic? 0
  • +

Page 1 of 1