This simple operation took me longer to figure out than I would like, the answer wasn’t obvious on msdn or in any of the searches I did so I figure I should just put it up here for anyone else who might look for it:
To select an item in a list view create an LVITEM structure, change a few of it’s fields and pass it to LVM_SETITEMSTATE:
// Select current item in the list
LVITEM item = {0};
item.mask = LVIF_STATE;
item.state = item.stateMask = LVIS_SELECTED;
SendMessage(mhProductList, LVM_SETITEMSTATE, mCurrentSettings, (LPARAM)&item);
Oh and if you’re trying to turn on whole line section you’ll need to use the extended styles:
// Set extended styles
SendMessage(hWndListView, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT);