CListBox::SetColumnWidth

更新 : 2007 年 11 月

複数桁のリスト ボックス (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

その他の技術情報

CListBox のメンバ