Home > Software engineering >  The CListCtrl trigger thinking of a For loop
The CListCtrl trigger thinking of a For loop

Time:10-11

CListCtrl m_CList;
Cstrings strReturn=_T (" TEST ");
For (int I=m_CList. GetItemCount () - 1; i>=0; I -)
{
If (strReturn==m_CList. GetItemText (I, 1))
{
M_CList. Called DeleteItem (I);
}
}


the cycle like this?

CodePudding user response:

Ok, try it yourself not clear ~

CodePudding user response:

Do not recommend, I=CLISTCTRL GET this sentence if there are other threads in the list box operation can make the circulation anomalies

CodePudding user response:

Should pay attention to here, for the expression will only calculate, is not in every loop calculation expression,

So, obviously, when you remove elements, the for expression are not heavy, will be wrong

CodePudding user response:

 for (A; B; C) D; 
//equivalent to the
{
A;
While (1) {
if (! (B)) break;
D;
C;
}
}

CodePudding user response:

Miss zhao mean, is no problem! Int I=m_CList. GetItemCount () - 1; Can run once only, after removing the cycle number still remain the same!

CodePudding user response:

reference 4 floor zhao4zhong1 response:
 for (A; B; C) D; 
//equivalent to the
{
A;
While (1) {
if (! (B)) break;
D;
C;
}
}

Miss zhao mean, is no problem! Int I=m_CList. GetItemCount () - 1; Can run once only, after removing the cycle number still remain the same!

CodePudding user response:

I think no problem,

CodePudding user response:

Why not just use FindItem () want to traverse the contrast
  • Related