'Add' them. Look at the documention for ArrayList.
Printable View
i know there is this way to add:
and you repeat that line for each itemCode:myPlaylistsCollection .add(something);
put i don't want to manually add each item like that
so could you show me how to add them?
You don't need to 'repeat that line for each item'. The problem is that you are making a temp Playlist, but not putting it in your playlist collection (myPlaylistsCollection). I.e. you only have one item (the playlist) to add.Code:ArrayList myPlaylistsCollection = new ArrayList();
private void button1_Click(object sender, EventArgs e) //create playlist
{
Playlist temp = new Playlist(textBoxPlaylist.Text);
foreach(string name in PlaylistTracks.Items)
{
temp.addSong(name);
}
// Add 'temp' to 'myPlaylistsCollection'
}
ok thanks so i added this line:
now i want to display the playlist names in a listbox on the first formCode:myPlaylistsCollection.Add(temp);
its just an empty listbox right now:
Code:private void listBoxPlaylist_SelectedIndexChanged(object sender, EventArgs e)
{
//need to display the playlists created
}
That's it. :)
You just need to loop through myPlaylistsCollection, getting the names of each Playlist in turn. Then add these names to the listbox.
If you don't know how to do these steps, please look up the documentation on MSDN. You'll need to look up ArrayList and ListBox.
Forums are better for things which can't be easily googled.
ok I tried adding a loop but it doesn't recognize myPlaylistsCollections since its in a different form. Do i need to add something so it can read the code from the second form?Quote:
You just need to loop through myPlaylistsCollection, getting the names of each Playlist in turn.
From the questions you are asking, it seems that you don't have a good understanding of the basics. I really think you would benefit from working through some tutorials on collections, forms and controls. There are plenty online - just google them.
In particular, look for a tutorial showing how to return results from a Form. That will help you with your current question.