How do I change styles to an already created list control?

630 Views Asked by At

I have created

 pMyListControl = new CListCtrl; 
    pMyListControl->Create(WS_CHILD| WS_VISIBLE | WS_VSCROLL | LBS_NOTIFY | LVS_REPORT | LVS_SINGLESEL, rect, pTabControl, LIST_ID);

On some tabs the list will only allow single select like the above code, but on some tabs it will not have LVS_SINGLESEL to allow for multiple item selections. The list is created with a default tab that doesn't allow for multiple selection.

Can I change the style, without having to create a new listcntrl depending on my tab selection? Is there a method for this?

1

There are 1 best solutions below

0
Remy Lebeau On

You can use the CWnd::ModifyStyle() method, eg:

// turn on single selection
pMyListControl->ModifyStyle(0, LVS_SINGLESEL);

// turn off single selection
pMyListControl->ModifyStyle(LVS_SINGLESEL, 0);