CListBox多选情况处理方法
2024-10-14 05:50:21
如ListBox的内容如下,蓝色代表选中的内容
列表 | 索引 | 删除时索引 |
item1 | 0 | 0 |
item2 | 1 | 0 |
item3 | 2 | |
item4 | 3 | 1 |
删除所有选中列:
void CListBox::_DeletSelectedItem() { CArray<int,int> ar; int nCount = CListBox::GetSelCount(); ar.SetSize(nCount); if (CListBox::GetSelItems(nCount,ar.GetData())==LB_ERR) return; for (int i=0; i<nCount; i++){ ItemData* rf = (ItemData*)(CListBox::GetItemData(ar[i]-i)); if (rf != NULL) delete rf; CListBox::SetItemData(ar[i]-i,0); CListBox::DeleteString(ar[i]-i); } }
ar数组是存储选中内容的索引,CListBox::DeleteString(INT nItem)删除的机制是从0往后删除每删除一项所有列的索引减一。故要得到正确的索引应为(ar[i]-i)
最新文章
- 前端试题本(Javascript篇)
- 1.javascript篇(基础)
- CentOS 下运维自动化 Shell 脚本之 expect
- 【转】Mysql中的排序规则utf8_unicode_ci、utf8_general_ci的区别总结
- php--递归调用
- 黑盒测试用例设计方法&;理论结合实际 ->; 错误推断法
- my.cnf已经存在,影响安装--mysql
- NVIDIA 显卡温度提示过高,显卡温度高99度怎么办?
- [原]C语言实现的快速排序,采用分治策略,递归实现
- 201521123091 《Java程序设计》第6周学习总结
- 【BZOJ3884】上帝与集合的正确用法(欧拉定理,数论)
- 回忆曾经的SSM框架实现文件上传
- css控制table间距
- complex类
- 项目管理第一篇(PROJECT MANAGEMENT A Systems Approach to Planning, Scheduling, and Controlling)
- 当多线程并发遇到Actor
- 如何利用FastReport.Net 设计并导出报表?
- 谈一谈JUnit神奇的报错 java.lang.Exception:No tests found matching
- Referrer Policy 介绍
- WebRTC网关服务器单端口方案实现
热门文章
- 如何用 .Net 开发
- bug__android studio 出现布局文件不提示,且点击代码不能跟踪代码
- oracle kill session
- Python多线程互斥锁
- Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again.
- Android学习起步 - Button按钮及事件处理
- Linux里的2>;&;1
- Linux 命令 创建文件
- 用adox 取 access 自增列
- Error:Execution failed for task &#39;:app:dexDebug&#39;.