Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set an item in CListCtrl as selected?

ClistCtrl is set to single selection & single column in report view with no header.

I have tried SetItemState(0,LVIS_SELECTED,LVIF_STATE) and
SetSelectionMark(int index) but these don't work.

like image 209
DarshanG Avatar asked Nov 13 '09 13:11

DarshanG


People also ask

How do you get selected items for CListCtrl?

RE: How to get the index of selected item of a CListCtrl int index = pList->GetNextSelectedItem(pos); AfxMessageBox("Item %d was selected!\


1 Answers

Provided that the index of the item fo be selected is w_nCurIdx, Use the following code

m_pSPSMapList.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
m_pSPSMapList.SetItemState(w_nCurIdx, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
like image 61
Michael Haephrati Avatar answered Oct 05 '22 01:10

Michael Haephrati