单选Win32 ListView(常用控件)
我正在使用 C++ 中的 Common Controls 6.0 中的 ListView 控件,并且我需要 ListView 仅用于单选。
所有更高级别的控件都具有此功能(例如.Net 和 Qt),但我想它们是基于此控件的深处的某个地方。关于如何使其成为单选列表的任何想法?
以防万一它有所不同,这是我当前的创建语句:
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
);
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
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要标志
LVS_SINGLESEL
该标志必须在窗口创建中使用,创建后更改它将会失败 - 如果不创建 2 个单独的控件,则无法在单选和多选之间切换。
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.
有一个 LVS_SINGLESEL 样式。只需将其与您已有的样式进行“或”操作即可。
There's a LVS_SINGLESEL style. Just OR that in with the styles you already have.
您需要
LVS_SINGLESEL
。请参阅:http://msdn.microsoft.com/en-us/library/bb774739 .aspxYou want
LVS_SINGLESEL
. See: http://msdn.microsoft.com/en-us/library/bb774739.aspx如果您不想添加任何代码,只需编辑对话框 RC 属性即可。
If you don't want add any code, just edit the Dialog RC property.