单选Win32 ListView(常用控件)

发布于 2024-09-27 04:36:05 字数 445 浏览 0 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

葵雨 2024-10-04 04:36:05

您需要标志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.

沉睡月亮 2024-10-04 04:36:05

有一个 LVS_SINGLESEL 样式。只需将其与您已有的样式进行“或”操作即可。

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

狼亦尘 2024-10-04 04:36:05

如果您不想添加任何代码,只需编辑对话框 RC 属性即可。
输入图片此处描述

If you don't want add any code, just edit the Dialog RC property.
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文