简体   繁体   English

单选 Win32 ListView(常用控件)

[英]Single-select Win32 ListView (Common Controls)

I'm using the ListView control from Common Controls 6.0 in C++ and I need the ListView to be single-select only.我在 C++ 中使用 Common Controls 6.0 中的 ListView 控件,我只需要 ListView 是单选的。

All of the higher level controls have this feature (eg .Net and Qt), but I imagine they are based on this control deep down somewhere.所有更高级别的控件都具有此功能(例如 .Net 和 Qt),但我想它们在某个地方基于此控件。 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:以防万一它有所作为,这是我当前的 create 语句:

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你想要标志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.此标志必须在窗口创建中使用,创建后更改它会失败 - 无法在不创建 2 个单独控件的情况下在单选和多选之间切换。

There's a LVS_SINGLESEL style.有一个 LVS_SINGLESEL 风格。 Just OR that in with the styles you already have.只需将其与您已有的样式结合即可。

You want LVS_SINGLESEL .你想要LVS_SINGLESEL See: http://msdn.microsoft.com/en-us/library/bb774739.aspx请参阅: http : //msdn.microsoft.com/en-us/library/bb774739.aspx

If you don't want add any code, just edit the Dialog RC property.如果您不想添加任何代码,只需编辑 Dialog RC 属性。 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM