|
-
March 26th, 2012, 03:37 PM
#16
Re: serialization question
 Originally Posted by beginner91
yes you are right. so how do i put the playlists in there?
'Add' them. Look at the documention for ArrayList.
-
March 28th, 2012, 06:13 AM
#17
Re: serialization question
i know there is this way to add:
Code:
myPlaylistsCollection .add(something);
and you repeat that line for each item
put i don't want to manually add each item like that
so could you show me how to add them?
-
March 28th, 2012, 06:28 AM
#18
Re: serialization question
 Originally Posted by beginner91
i know there is this way to add:
Code:
myPlaylistsCollection .add(something);
and you repeat that line for each item
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'
}
-
March 28th, 2012, 06:36 AM
#19
Re: serialization question
ok thanks so i added this line:
Code:
myPlaylistsCollection.Add(temp);
now i want to display the playlist names in a listbox on the first form
its just an empty listbox right now:
Code:
private void listBoxPlaylist_SelectedIndexChanged(object sender, EventArgs e)
{
//need to display the playlists created
}
-
March 28th, 2012, 06:50 AM
#20
Re: serialization question
 Originally Posted by beginner91
ok thanks so i added this line:
Code:
myPlaylistsCollection.Add(temp);
That's it. 
 Originally Posted by beginner91
now i want to display the playlist names in a listbox on the first form
its just an empty listbox right now:
Code:
private void listBoxPlaylist_SelectedIndexChanged(object sender, EventArgs e)
{
//need to display the playlists created
}
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.
-
March 30th, 2012, 10:03 AM
#21
Re: serialization question
You just need to loop through myPlaylistsCollection, getting the names of each Playlist in turn.
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?
-
March 30th, 2012, 12:04 PM
#22
Re: serialization question
 Originally Posted by beginner91
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?
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|