void AdjustCtrlColumns(CListCtrl& lst)
{
CHeaderCtrl*pHead=lst.GetHeaderCtrl();
ASSERT(pHead);
if (pHead)
{
lst.SetRedraw(FALSE);
for (int iCurrCol=0;iCurrCol<pHead->GetItemCount();++iCurrCol)
{
lst.SetColumnWidth(iCurrCol,LVSCW_AUTOSIZE);
int nCurrWith=lst.GetColumnWidth(iCurrCol);
lst.SetColumnWidth(iCurrCol,LVSCW_AUTOSIZE_USEHEADER);
int nColHdrWidth=lst.GetColumnWidth(iCurrCol);
lst.SetColumnWidth(iCurrCol,max(nColHdrWidth,nCurrWith));
}
lst.SetRedraw();
lst.Invalidate();
}
}
本文介绍了一个用于调整CListCtrl中各列宽度的方法。通过使用LVSCW_AUTOSIZE和LVSCW_AUTOSIZE_USEHEADER,确保了列表视图控件的列宽能够根据内容和头部宽度自动调整至合适大小。
6445

被折叠的 条评论
为什么被折叠?



