请教高手:ListView中ColumnHerder宽度的设定 我需要设定ListView每一栏的宽度,但是MSDN中只有自动设置,怎样设定自己需要的宽度?请各位高手帮忙,不胜感激 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不是高手,最近手头有这个例子,我也没完全看懂,但相信能满足你的要求。// the heading text is in the format column 0 text,column 1 width;column 2 text,column 3 width;etc.BOOL CSortListCtrl::SetHeadings( const CString& strHeadings ){ int iStart = 0; for( ;; ) { const int iComma = strHeadings.Find( _T(','), iStart ); if( iComma == -1 ) break; const CString strHeading = strHeadings.Mid( iStart, iComma - iStart ); iStart = iComma + 1; int iSemiColon = strHeadings.Find( _T(';'), iStart ); if( iSemiColon == -1 ) iSemiColon = strHeadings.GetLength(); const int iWidth = atoi( strHeadings.Mid( iStart, iSemiColon - iStart ) ); iStart = iSemiColon + 1; if( InsertColumn( m_iNumColumns++, strHeading, LVCFMT_LEFT, iWidth ) == -1 ) return FALSE; } return TRUE;}调用:m_SortListCtrl.SetHeadings( _T("Name,50;Access time,150;Length,50;") ); ///设置列头信息 通过GetListCtrl 获得CListCtrl后用SetColumnWidth设置列宽 添加MFC类的问题 GDI+的Font销毁问题 用vc作柱状图 在VC中,如何添加右键菜单(像WinRAR那样) 关于线程的等待问题,是高手的请进,灌水者勿扰,非常感谢 VC开发读写DWG文件接口 怎样让对话框接收OnKeyDown消息? 大家帮我出个主意吧!关于活动视频录像及回放问题。 出主意者都有分,不够另开贴。 如何让我的程序在win2000任务栏管理器中不显示? 菜鸟请您帮助1 DirectShow的例子 dll导出包含vector成员的类
// the heading text is in the format column 0 text,column 1 width;column 2 text,column 3 width;etc.
BOOL CSortListCtrl::SetHeadings( const CString& strHeadings )
{
int iStart = 0; for( ;; )
{
const int iComma = strHeadings.Find( _T(','), iStart ); if( iComma == -1 )
break; const CString strHeading = strHeadings.Mid( iStart, iComma - iStart ); iStart = iComma + 1; int iSemiColon = strHeadings.Find( _T(';'), iStart ); if( iSemiColon == -1 )
iSemiColon = strHeadings.GetLength(); const int iWidth = atoi( strHeadings.Mid( iStart, iSemiColon - iStart ) );
iStart = iSemiColon + 1; if( InsertColumn( m_iNumColumns++, strHeading, LVCFMT_LEFT, iWidth ) == -1 )
return FALSE;
} return TRUE;
}调用:m_SortListCtrl.SetHeadings( _T("Name,50;Access time,150;Length,50;") ); ///设置列头信息
SetColumnWidth设置列宽