【Duilib】 List控件支持多选和获取选择的多条数据

问题

使用Duilib库写的一个UI页面用到了List控件,功能变动想支持选择多行数据。

分析

1、List控件本身支持使用SetMultiSelect接口设置是否多选:

cpp 复制代码
void SetMultiSelect(bool bMultiSel);

2、List控件本身支持使用GetNextSelItem接口获取选中的下一个索引项:

cpp 复制代码
int GetNextSelItem(int nItem) const;

解决

cpp 复制代码
// ...
// 初始化控件时设置支持多选
auto pListUI = static_cast<DuiLib::CListUI*>(m_pm.FindControl(_T("list_data")));
pListUI->SetMultiSelect(true);

// ...
// 获取选择的索引时
int nSel = -1;
int nNextSel = m_pListDataUI->GetNextSelItem(nSel);
while (nNextSel >= 0)
{
	// ...
    nNextSel = m_pListDataUI->GetNextSelItem(nNextSel);
}
相关推荐
hikktn12 分钟前
Excel 日期格式统一治理:从“显示不全“到“自动兼容“的完整方案
windows·python·excel
caimouse29 分钟前
Reactos 第 6 章 进程间通信 — 6.8 本地过程调用(LPC)与 6.9 视窗报文(Message)
windows
caimouse35 分钟前
Reactos 第 6 章 进程间通信
windows
alwaysrun40 分钟前
C++之常量体系const
c++·后端·程序员
郝学胜_神的一滴41 分钟前
CMake 016:深入浅出变量核心用法
c++·cmake
私人珍藏库43 分钟前
【PC】ActivePresenter(屏幕录制软件) Pro v10.5.1 多语便携版
windows·pc·工具·软件·多功能
学逆向的1 小时前
C++模板
开发语言·c++·网络安全
你住过的屋檐1 小时前
【claude code】claude code在windows下安装使用教程,以及在idea中使用claude code自动AI写代码
人工智能·windows·intellij-idea
凡人叶枫1 小时前
Effective C++ 条款24:若所有参数皆须要类型转换,请为此采用 non-member 函数
linux·前端·c++·算法·嵌入式开发
caimouse1 小时前
Reactos 第 5 章 进程与线程 — 5.13 Windows的跨进程操作
windows