CListCtrl自适应宽度

 

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

你可能感兴趣的:(CListCtrl自适应宽度)