CListCtrl - 如何启用多重选择

发布于 2024-07-12 09:07:04 字数 122 浏览 7 评论 0原文

我正在为 Windows Mobile 创建 MFC 应用程序,但不知道如何启用列表控件 (CListCtrl) 的多重选择。 在属性面板中“单选”设置为“False”,但仍然无法选择多个项目。

任何想法?

I am creating a MFC application for Windows Mobile and don't know how to enable multiple selection for List Control (CListCtrl). In properties panel Single Selection is set to False but still can't select multiple items.

Any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

灼痛 2024-07-19 09:07:04

我从未针对 Windows Mobile,但您可以尝试以下操作:

list.ModifyStyle(LVS_SINGLESEL, 0);

I have never targeted Windows Mobile but you might try the following:

list.ModifyStyle(LVS_SINGLESEL, 0);

时光清浅 2024-07-19 09:07:04

如果您希望以编程方式执行此操作,则 CWnd 基础的 ModifyStyle 方法将起作用(请参阅 Diego 的帖子),或者如果您将控件放置在对话框上,则可以在资源编辑器中定义属性。

ModifyStyle method of CWnd base will work (see post from Diego) if you desire to do this programmatically OR you can define the attribute within the Resource Editor IF your placing the control on a dialog.

流云如水 2024-07-19 09:07:04

所有 ListView 窗口样式均在 CommCtrl.h 头文件中定义。 在 Microsoft 网站上查看此页面

ListView 控件的默认设置允许多项选择。 如果您只需要允许从列表中进行单个选择,请使用以下代码:

m_ListControl.ModifyStyle(NULL, LVS_SINGLESEL, 0); 

m_ListControl 是列表控件的变量。 您可以选择上页提到的许多其他样式。

这是另一个例子:

ListView_SetExtendedListViewStyle(::GetDlgItem(m_hWnd, IDC_LIST1), LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);

All ListView window styles are defined in the CommCtrl.h header file. Check this page on Microsoft's website.

The default setting for a ListView control allows multiple selections. If you need to allow only single selection from the list, then use below code:

m_ListControl.ModifyStyle(NULL, LVS_SINGLESEL, 0); 

m_ListControl is the variable for your List Control. You can many other styles mentioned on above page.

Here is another example:

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