View Single Post
Old Feb 1st, 2007, 5:49 PM   #1
BlazingWolf
Hobbyist Programmer
 
Join Date: Sep 2004
Posts: 207
Rep Power: 5 BlazingWolf is on a distinguished road
Flow Control Issue

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);
         }
}
__________________
_______________________________
BlazingWolf
BlazingWolf is offline   Reply With Quote