Ok, this one just doesn't make any sense to me. In the code below if I remove the comments around the nested loop the if statement below it doesn't execute, but if that loop is commented out it executes perfectly.
Why?
foreach (TreeViewItem tviGrp in tvcBuddyList)
{
/*--------------------------
//Remove from any groups the user may be in
foreach (TreeViewItem tviUser in tviGrp.Items)
{
if (tviUser.Name == user.Name)
{
tviGrp.Items.Remove(tviUser);
}
}
----------------------------*/
//Add the user to the offline group
if (tviGrp.Name == "Offline")
{
TreeViewItem tviUser = new TreeViewItem();
tviUser.Header = user.Name;
tviUser.Name = user.Name;
tviGrp.Items.Add(tviUser);
}
}