CListBox::SetColumnWidth
Sets the width in pixels of all columns in a multicolumn list box (created with the LBS_MULTICOLUMN style).
void SetColumnWidth(
int cxWidth
);
Параметры
- cxWidth
Specifies the width in pixels of all columns.
Пример
// Find the pixel width of the largest item.
CString str;
CSize sz;
int dx = 0;
CDC* pDC = myListBox.GetDC();
for (int i=0;i < myListBox.GetCount();i++)
{
myListBox.GetText( i, str );
sz = pDC->GetTextExtent(str);
if (sz.cx > dx)
dx = sz.cx;
}
myListBox.ReleaseDC(pDC);
// Set the column width of the first column to be one and 1/3 units
// of the largest string.
myListBox.SetColumnWidth(dx*4/3);
Требования
Header: afxwin.h