CListBox::SetColumnWidth

voidSetColumnWidth(intcxWidth**);**

Parameters

cxWidth

Specifies the width in pixels of all columns.

Remarks

Sets the width in pixels of all columns in a multicolumn list box (created with the LBS_MULTICOLUMN style). 

Example

// The pointer to my multicolumn list box.
extern CListBox* pmyListBox;

// Find the pixel width of the largest item.
CString str;
CSize   sz;
int     dx=0;
CDC*    pDC = pmyListBox->GetDC();
for (int i=0;i < pmyListBox->GetCount();i++)
{
   pmyListBox->GetText( i, str );
   sz = pDC->GetTextExtent(str);

   if (sz.cx > dx)
      dx = sz.cx;
}
pmyListBox->ReleaseDC(pDC);

// Set the column width of the first column to be one and 1/3 units
// of the largest string.
pmyListBox->SetColumnWidth(dx*4/3);

CListBox OverviewClass MembersHierarchy Chart

See Also