原文链接: http://blog.csdn.net/benny5609/article/details/1967084

void CListCtrlExDlg::AdjustColumnWidth()
{
// SetRedraw(FALSE);
int nColumnCount = GetColumnCount();

for (int i = 0; i < nColumnCount; i++)
{
   m_wndList.SetColumnWidth(i, LVSCW_AUTOSIZE);
   int nColumnWidth = m_wndList.GetColumnWidth(i);
   m_wndList.SetColumnWidth(i, LVSCW_AUTOSIZE_USEHEADER);
   int nHeaderWidth = m_wndList.GetColumnWidth(i); 
   m_wndList.SetColumnWidth(i, max(nColumnWidth, nHeaderWidth));
}

// SetRedraw(TRUE);
}

int CListCtrlExDlg::GetColumnCount()
{
  CHeaderCtrl* pHeaderCtrl = m_wndList.GetHeaderCtrl();
    return (pHeaderCtrl->GetItemCount());
}

05-11 14:47