如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)

最新文章

  1. 前端试题本(Javascript篇)
  2. 1.javascript篇(基础)
  3. CentOS 下运维自动化 Shell 脚本之 expect
  4. 【转】Mysql中的排序规则utf8_unicode_ci、utf8_general_ci的区别总结
  5. php--递归调用
  6. 黑盒测试用例设计方法&amp;理论结合实际 -&gt; 错误推断法
  7. my.cnf已经存在,影响安装--mysql
  8. NVIDIA 显卡温度提示过高,显卡温度高99度怎么办?
  9. [原]C语言实现的快速排序,采用分治策略,递归实现
  10. 201521123091 《Java程序设计》第6周学习总结
  11. 【BZOJ3884】上帝与集合的正确用法(欧拉定理,数论)
  12. 回忆曾经的SSM框架实现文件上传
  13. css控制table间距
  14. complex类
  15. 项目管理第一篇(PROJECT MANAGEMENT A Systems Approach to Planning, Scheduling, and Controlling)
  16. 当多线程并发遇到Actor
  17. 如何利用FastReport.Net 设计并导出报表?
  18. 谈一谈JUnit神奇的报错 java.lang.Exception:No tests found matching
  19. Referrer Policy 介绍
  20. WebRTC网关服务器单端口方案实现

热门文章

  1. 如何用 .Net 开发
  2. bug__android studio 出现布局文件不提示,且点击代码不能跟踪代码
  3. oracle kill session
  4. Python多线程互斥锁
  5. Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again.
  6. Android学习起步 - Button按钮及事件处理
  7. Linux里的2&gt;&amp;1
  8. Linux 命令 创建文件
  9. 用adox 取 access 自增列
  10. Error:Execution failed for task &#39;:app:dexDebug&#39;.