This documentation is archived and is not being maintained.

CComboBox::GetTopIndex 

Retrieves the zero-based index of the first visible item in the list-box portion of the combo box.


int GetTopIndex( ) const;

The zero-based index of the first visible item in the list-box portion of the combo box if successful, CB_ERR otherwise.

Initially, item 0 is at the top of the list box, but if the list box is scrolled, another item may be at the top.

// The pointer to my combo box.
extern CComboBox* pmyComboBox;

// Want an item in the bottom half to be the first visible item.
int n = pmyComboBox->GetCount()/2;
if (pmyComboBox->GetTopIndex() < n)
{
   pmyComboBox->SetTopIndex(n);
   ASSERT(pmyComboBox->GetTopIndex() == n);
}
Show: