CListBox::SetCaretIndex

int SetCaretIndex( int nIndex, BOOL bScroll = TRUE );

Return Value

LB_ERR if an error occurs.

Parameters

nIndex

Specifies the zero-based index of the item to receive the focus rectangle in the list box.

bScroll

If this value is 0, the item is scrolled until it is fully visible. If this value is not 0, the item is scrolled until it is at least partially visible.

Remarks

An application calls the SetCaretIndex member function to set the focus rectangle to the item at the specified index in a multiple-selection list box. If the item is not visible, it is scrolled into view.

Example

// The pointer to my list box.
extern CListBox* pmyListBox;

// Set the caret to be the middle item.
pmyListBox->SetCaretIndex(pmyListBox->GetCount()/2);
ASSERT(pmyListBox->GetCaretIndex() == pmyListBox->GetCount()/2);

CListBox OverviewClass MembersHierarchy Chart

See Also   CListBox::GetCaretIndex, LB_SETCARETINDEX