zoukankan      html  css  js  c++  java
  • (转)MFC的ClistCtrl删除选中多行项目

    MFC的ClistCtrl控件添加了多行数据后,若要删除选中的多行数据,可以使用ClistCtrl的成员函数,在网上找了很多例子,发现都有问题,因为在删除ClistCtrl行的时候,删除行下面的行会上移,那么下一个要删除的行的索引会改变,导致删除的是删除行下两行位置的数据,删除不完全。

    使用下面代码可完全删除选中行:

    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    void CBatchConvert::OnDeleteFile()
    {
        // TODO: 在此添加命令处理程序代码
        POSITION pos = m_ctrlBatchFile.GetFirstSelectedItemPosition();
        while(pos)
        {
            int nIndex = m_ctrlBatchFile.GetNextSelectedItem(pos);
            m_ctrlBatchFile.DeleteItem(nIndex);
            pos = m_ctrlBatchFile.GetFirstSelectedItemPosition(); //这步很重要,不然删除不完全
        }
    }

    原文出处:http://www.zoudaokou.com/index.php/archives/103

    这里值得注意一下

  • 相关阅读:
    动态加载并执行Win32可执行程序
    二维码登录
    深度神经网络实现图像理解的原理
    NET Core Docker部署
    EventStore的设计思路
    NET Core,Ubuntu运行
    Tensorflow 神经网络
    System.Reflection.Emit学习
    泛型 "new的性能"
    蚁群算法
  • 原文地址:https://www.cnblogs.com/lihaiping/p/clistctrl.html
Copyright © 2011-2022 走看看