【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);
}
相关推荐
AvocadoZeroOneOI3 小时前
B4500 [GESP202603 三级] 凯撒密码 详细解题报告
c++·算法
whitelbwwww5 小时前
cuBLAS--CUDA高性能线性代数计算库--第一部分
c++·线性代数·gpu算力·cuda c++
李小白杂货铺6 小时前
Windows 桌面 GUI 原型快速开发技术选型指南(Mac 开发 + Windows 交付场景)
windows·原型·gui·原型开发·技术选型·快速开发·技术路线
eggwyw7 小时前
C++设计模式之解释器模式
开发语言·c++
承渊政道10 小时前
magic-resume简历工具教程:Windows部署、在线编辑与远程访问
windows·远程访问·在线编辑·简历制作·工具教程·magic-resume
我不会插花弄玉20 小时前
13.多路转接epoll【由浅入深-网络】
网络·c++·epoll
郝学胜-神的一滴1 天前
Effective STL 条款03:容器中的对象复制要廉价且正确
开发语言·数据结构·c++·算法·rpc·stl
西西弗Sisyphus1 天前
C++ explicit 关键字工程实践
开发语言·c++
观察员1 天前
告别频繁锁屏:5行 PowerShell 脚本实现 Windows 自动防休眠
windows·命令行
Funlang1 天前
在 Windows 95 上写前端
前端·javascript·windows