Udostępnij za pośrednictwem


CListBox::GetItemHeight

Określa wysokość elementów w polu listy.

int GetItemHeight(
   int nIndex 
) const;

Parametry

  • nIndex
    Określa wyświetlanego elementu w polu listy.Ten parametr jest używany tylko wtedy, gdy pole listy ma LBS_OWNERDRAWVARIABLE stylu; inaczej należy go ustawić na 0.

Wartość zwracana

Wysokość w pikselach elementów w polu listy.Jeśli pole listy ma LBS_OWNERDRAWVARIABLE styl, zwracana jest wartość wysokości element określony przez nIndex.Jeśli wystąpi błąd, zwracana jest wartość LB_ERR.

Przykład

// Set the height of every item so the item
// is completely visible.
CString str;
CSize   sz;
CDC*    pDC = m_myListBox.GetDC();
for (int i=0;i < m_myListBox.GetCount();i++)
{
   m_myListBox.GetText( i, str );
   sz = pDC->GetTextExtent(str);

   // Only want to set the item height if the current height
   // is not big enough.
   if (m_myListBox.GetItemHeight(i) < sz.cy)
      m_myListBox.SetItemHeight( i, sz.cy );
}
m_myListBox.ReleaseDC(pDC);

Wymagania

Nagłówek: afxwin.h

Zobacz też

Informacje

Klasa CListBox

Wykres hierarchii

LB_GETITEMHEIGHT

CListBox::SetItemHeight