i=0;
while (ListCtrl.DeleteColumn(i++)!=0);
Here is how I create all columns :
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT ;
lvc.pszText = _T("Noms Prénoms");
lvc.cx = MaxWidthOfStudents(GetDC());
lvc.fmt = LVCFMT_LEFT;
ListCtrl.InsertColumn(0,&lvc);
for(i = 1; i<=nbOfMarks; i++)
{
lvc.pszText = _T("N°")+Tools.ConvertIntToString(i);
lvc.cx = 40;
lvc.fmt = LVCFMT_RIGHT;
ListCtrl.InsertColumn(i,&lvc);
}
lvc.pszText = _T("Moy");
lvc.cx = 40;
lvc.fmt = LVCFMT_RIGHT;
ListCtrl.InsertColumn(nbOfMarks+1,&lvc);
when you want to delete all column from an ListCtrl you only need to write
while( ListCtrl.DeleteColumn( 0 ) );
Because, if you delete the first column, the second column became index 0,
the thierd index 1 and so on. If you increment the indexcounter, you jump
over column and so they will not deleted. For example, you have four column
and delete this columns with you code, the second and fourth column will not
deleted.
Matthias
BURGARD Olivier schrieb in Nachricht
<358F86CB...@essaim.univ-mulhouse.fr>...
I didn't know that the index changes when I call DeleteColumn...
Thanks for your help.