次の方法で共有


CListBox::SetColumnWidth

複数列リスト ボックスのすべての列の幅をピクセル単位で設定します ( LBS_MULTICOLUMN のスタイルで作成されます)。

void SetColumnWidth(
   int cxWidth 
);

パラメーター

  • cxWidth
    すべての列の幅をピクセル単位で指定します。

使用例

// 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);

必要条件

ヘッダー: afxwin.h

参照

関連項目

CListBox クラス

階層図

LB_SETCOLUMNWIDTH