CListBox::SetCurSel

intSetCurSel(intnSelect**);**

Return Value

LB_ERR if an error occurs.

Parameters

nSelect

Specifies the zero-based index of the string to be selected. If nSelect is –1, the list box is set to have no selection.

Remarks

Selects a string and scrolls it into view, if necessary. When the new string is selected, the list box removes the highlight from the previously selected string.

Use this member function only with single-selection list boxes. It cannot be used to set or remove a selection in a multiple-selection list box.

Example

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

// Select the last item in the list box.
int nCount = pmyListBox->GetCount();
if (nCount > 0)
   pmyListBox->SetCurSel(nCount-1);

CListBox OverviewClass MembersHierarchy Chart

See Also   , CListBox::GetCurSel