Pergunta

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
);
Foi útil?

Solução

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.

Outras dicas

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top