![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Sep 2004
Posts: 207
Rep Power: 4
![]() |
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 |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Removing items from a list you're in the middle enumerating over is usually not a good idea. That may be where the problem stems from.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Coding standards without control? | martinig | Other Programming Languages | 1 | Dec 4th, 2006 7:04 AM |
| questions on windows sendMessage and RichEdit control | nomer | C++ | 1 | Mar 3rd, 2006 2:51 AM |
| IR control | firehawk | Assembly | 0 | Feb 25th, 2006 8:34 AM |
| C programing control of the Serial Port. | Light | C++ | 5 | Feb 24th, 2005 2:14 PM |
| Show web user control hidden | see07 | C# | 1 | Feb 2nd, 2005 10:35 AM |