MFC vc++ deleting column in list view control
-
In the blow code snippet, the DeleteColumn parameters takes 0 instead of "i" from the for loop. Why do we use 0 there and when I try using "i" there it didn't completely delete the column. I can't understand the process.
int nColumnCount = m_myListCtrl.GetHeaderCtrl()->GetItemCount();
// Delete all of the columns. for (int i=0; i < nColumnCount; i++) { m\_myListCtrl.DeleteColumn(0);// here why do we use 0 instead of "i" and when I use //"i" it didn't completely delete the column. }
-
In the blow code snippet, the DeleteColumn parameters takes 0 instead of "i" from the for loop. Why do we use 0 there and when I try using "i" there it didn't completely delete the column. I can't understand the process.
int nColumnCount = m_myListCtrl.GetHeaderCtrl()->GetItemCount();
// Delete all of the columns. for (int i=0; i < nColumnCount; i++) { m\_myListCtrl.DeleteColumn(0);// here why do we use 0 instead of "i" and when I use //"i" it didn't completely delete the column. }
After you have deleted the column 0 the next column (the former column 1) becomes the column 0. Another way to delete all the columns:
for (int i = nColumnCount - 1; i >= 0; i--) { m\_myListCtrl.DeleteColumn(i); }
-
After you have deleted the column 0 the next column (the former column 1) becomes the column 0. Another way to delete all the columns:
for (int i = nColumnCount - 1; i >= 0; i--) { m\_myListCtrl.DeleteColumn(i); }
Okay now I understand. Thanks :)