CListBox::SetItemHeight

Sets the height of items in a list box.

int SetItemHeight(
   int nIndex,
   UINT cyItemHeight 
);

Parameters

  • nIndex
    Specifies the zero-based index of the item in the list box. This parameter is used only if the list box has the LBS_OWNERDRAWVARIABLE style; otherwise, it should be set to 0.

  • cyItemHeight
    Specifies the height, in pixels, of the item.

Return Value

LB_ERR if the index or height is invalid.

Remarks

If the list box has the LBS_OWNERDRAWVARIABLE style, this function sets the height of the item specified by nIndex. Otherwise, this function sets the height of all items in the list box.

Example

// Set the height of every item to be the
// vertical size of the item's text extent.
CString str;
CSize   sz;
CDC*    pDC = myListBox.GetDC();
for (int i = 0; i < myListBox.GetCount(); i++)
{
   myListBox.GetText(i, str);
   sz = pDC->GetTextExtent(str);

   myListBox.SetItemHeight(i, sz.cy);
}
myListBox.ReleaseDC(pDC);

Requirements

Header: afxwin.h

See Also

Reference

CListBox Class

Hierarchy Chart

CListBox::GetItemHeight

LB_SETITEMHEIGHT

Other Resources

CListBox Members