Niko Gamulin
Niko Gamulin

Reputation: 66565

CListCtrl - how to enable multiple selection

I am creating a MFC application for Windows Mobile and don't know how to enable multiple selection for List Control (CListCtrl). In properties panel Single Selection is set to False but still can't select multiple items.

Any idea?

Upvotes: 1

Views: 11112

Answers (3)

Murali Krishna M.
Murali Krishna M.

Reputation: 77

All ListView window styles are defined in the CommCtrl.h header file. Check this page on Microsoft's website.

The default setting for a ListView control allows multiple selections. If you need to allow only single selection from the list, then use below code:

m_ListControl.ModifyStyle(NULL, LVS_SINGLESEL, 0); 

m_ListControl is the variable for your List Control. You can many other styles mentioned on above page.

Here is another example:

ListView_SetExtendedListViewStyle(::GetDlgItem(m_hWnd, IDC_LIST1), LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);

Upvotes: 0

SAMills
SAMills

Reputation: 456

ModifyStyle method of CWnd base will work (see post from Diego) if you desire to do this programmatically OR you can define the attribute within the Resource Editor IF your placing the control on a dialog.

Upvotes: 0

Captain Sensible
Captain Sensible

Reputation: 5027

I have never targeted Windows Mobile but you might try the following:

list.ModifyStyle(LVS_SINGLESEL, 0);

Upvotes: 4

Related Questions