Sorry, I am just using a regular treeView control, one that is dragged from the toolbox to the designer form. Yes, I have a continuous play radiobutton. The code I have is within a timer. I am using Windows Media Player control to check a label for "MediaEnded" event that fires in Windows Media Player when a song ends. When the user selects a song to play the timer starts. Here is the code I have for right now.
private void mainTimer_Tick_1(object sender, EventArgs e)
{
mainTimer.Interval = 3;
if (checkLabel.Text == "MediaEnded")
{
if (rbRepeat.Checked == true)
{
PlaySong();
checkLabel.Text = "";
}
if (rbContinuous.Checked == true)
{
checkLabel.Text = "";
try
{
mainTreeView.SelectedNode = mainTreeView.SelectedNode.NextNode;
PlaySong();
checkLabel.Text = "";
}
catch
{
mainTreeView.SelectedNode = mainTreeView.SelectedNode.FirstNode;
label5.Text = mainTreeView.SelectedNode.ToString();
PlaySong();
checkLabel.Text = "";
}
PlaySong() is a method I made that plays a song which works fine. The repeat function also works fine. The try block in the rbContinuous.Checked == true is where errors occur when the user would reach "Song3" in continuous mode and try to go to a Song4 when one doesn't exist. The label5.Text is irrelevant, it was just me trying to figure out what is being returned, nothing is returned in FirstNode.
I tried your code above, however Visual Studio was listing exceptions. I am very unfamiliar with TreeView, is TreeViewNodes a way of copying the contents of a TreeView control? Visual Studio was underlining TreeViewNodes as "a namespace could not be found, are you missing a using directive or assembly reference?" I changed TreeViewNodes to TreeNode to see if that would work, and it did work, however, SubNodes was then underlined as an error. I changed SubNodes to Nodes and it was not underlined, then executed the code but it did not work for me.
Edit: I did get your code to execute, however, it only works as a repeat function for me, the song ends up replaying. I removed the code I had in the try block and replaced with a code similar to yours except, TreeViewNodes replaced as TreeNode and SubNodes replaced as Nodes.
Hopefully, this clears my problem up a little bit. Any help would be appreciated and thank you guys for your replies! Sorry for the long post, just trying to figure this out if I can.