CListCtrl &listCtrl = GetListCtrl();
int nColumnCount = listCtrl.GetHeaderCtrl()->GetItemCount();
for (int i=0;i < nColumnCount;i++)
{
// Wrong method to delete all of the columns.
   listCtrl.DeleteColumn(i);//the second column can not be deleted
//Correct method to delete all columns
   listCtrl.DeleteColumn(0);//when first column is deleted, the second one become the first column,the third one is the second now.So you should always delete the first column
}

解决方案 »

  1.   

    不错。如果要全部删除用楼上的方法。要么就是
    CListCtrl &listCtrl = GetListCtrl();
    int nColumnCount = listCtrl.GetHeaderCtrl()->GetItemCount();
    for (int i=nColumnCount-1;i <0 ;i--)
    {
      listCtrl.DeleteColumn(i);
    }
      

  2.   

    不错。如果要全部删除用楼上的方法。要么就是
    CListCtrl &listCtrl = GetListCtrl();
    int nColumnCount = listCtrl.GetHeaderCtrl()->GetItemCount();
    for (int i=nColumnCount-1;i <0 ;i--)
    {
      listCtrl.DeleteColumn(i);
    }
      

  3.   

    也可以保留原状态然后重新CREATE
      

  4.   


    谢谢各位,不过多次调用增加、删除后视中会产生水平滚动条。无法去掉它!!to tangby(sinababy)
    重新生成后会覆盖原来的吗??