Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Retrieves the selection state of an item.
int GetSel(
int nIndex
) const;
Parameters
- nIndex
Specifies the zero-based index of the item.
Return Value
A positive number if the specified item is selected; otherwise, it is 0. The return value is LB_ERR if an error occurs.
Remarks
This member function works with both single- and multiple-selection list boxes.
To retrieve the index of the currently-selected list box item, use CListBox::GetCurSel.
Example
// Dump all of the items select state.
CString str;
for (int i=0;i < m_myListBox.GetCount();i+)
{
str.Format(_T("item %d: select state is %s\r\n"),
i,
m_myListBox.GetSel( i ) > 0 ? _T("true") : _T("false"));
AFXDUMP(str);
}
Requirements
Header: afxwin.h
See Also
Reference
Other Resources
Change History
Date |
History |
Reason |
---|---|---|
May 2009 |
Added links to CListBox::GetCurSel. |
Information enhancement. |