Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to delete all columns in a ClistCtrl ?

1,053 views
Skip to first unread message

BURGARD Olivier

unread,
Jun 23, 1998, 3:00:00 AM6/23/98
to

I must remove all columns (except one). But the last columns remains
when I do :

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);


MW

unread,
Jun 23, 1998, 3:00:00 AM6/23/98
to

Hi Olivier,

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>...

BURGARD Olivier

unread,
Jun 23, 1998, 3:00:00 AM6/23/98
to

Hi Matthias

I didn't know that the index changes when I call DeleteColumn...

Thanks for your help.


0 new messages