CListCtrl自适应宽度

 

原文链接: 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());
}

 

 

posted @ 2015-07-05 22:20  huhu0013  阅读(846)  评论(0编辑  收藏  举报