문제

I'm using the ListView control from Common Controls 6.0 in C++ and I need the ListView to be single-select only.

All of the higher level controls have this feature (e.g. .Net and Qt), but I imagine they are based on this control deep down somewhere. Any ideas on how I can get this to behave as a single-select list?


Just in case it makes a difference, here is my current create statement:

list = ::CreateWindowExW(
    0,
    WC_LISTVIEWW,
    NULL,
    WS_VISIBLE | WS_CHILD | WS_BORDER | LVS_SHOWSELALWAYS | LVS_REPORT | LVS_OWNERDATA,
    0,
    0,
    250,
    400,
    parentWindow,
    NULL,
    NULL,
    NULL
);
도움이 되었습니까?

해결책

You want the flag LVS_SINGLESEL

This flag must be used in window creation, changing it after creation will fail - can't toggle between single and multi select without creating 2 separate controls.

다른 팁

There's a LVS_SINGLESEL style. Just OR that in with the styles you already have.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top