CListCtrl::GetStringWidth

命令式最小的列宽显示所有给定的字符串。

int GetStringWidth(
   LPCTSTR lpsz 
) const;

参数

  • lpsz
    将确定宽度一个Null终止的字符串的地址。

返回值

宽度,以像素,该字符串指向由 lpsz。

备注

该返回的宽度考虑控件的当前字体和列边距,但是,一个小图标的不是宽度。

示例

        CString strColumn;
        int nWidth;

        // Insert six columns in the list view control. Make the width of
        // the column be the width of the column header plus 50%.
        for (int i = 0; i < 6; i++)
        {
            strColumn.Format(_T("column %d"), i);
            nWidth = 3*m_myListCtrl.GetStringWidth(strColumn)/2;
            m_myListCtrl.InsertColumn(i, strColumn, LVCFMT_LEFT, nWidth);
        }

要求

Header: afxcmn.h

请参见

参考

CListCtrl选件类

层次结构图

CListCtrl::GetColumnWidth