zoukankan      html  css  js  c++  java
  • listctrl查找定位 使用测试过还很好用

    35、listctrl查找定位  使用测试过还很好用 


    // 简单的查找函数
    // FindString(CListCtrl& , 查找内容 , 开始位置 , 到达底部时是否从头查找)

    int FindString(CListCtrl& list,LPCTSTR str,int startIndex,BOOL warp /* = TRUE */){
     int colCount = list.GetHeaderCtrl()->GetItemCount();
     CString* field = new CString[colCount];

     int index;
     if(startIndex < 0) index = 0;
     else index = startIndex + 1;

     BOOL isFind = FALSE;
     int out = -1;

     for(; index < list.GetItemCount(); index ++){
      for(int col = 0; col < colCount; col ++)
       field[col] = list.GetItemText(index,col);

      for(int col = 0; col < colCount; col ++){
       if(field[col].Find(str) != -1){
        out = index;
        isFind = TRUE;
        break;
       }
      }

      if(isFind) break;
     }

     delete[] field;
     field = 0;

     if(warp)
      if(!isFind)
       list.SetItemState(-1,0,LVIS_SELECTED);

     return out;


    /*************************************************/

    //测试
    CListCtrl& list;    // 需要查找的LIST
    CString str = "test";  //需要查找的字符串
    int index = -1;  //开始位置

    index = FindString(list,str,index,TRUE);
    if(index != -1){
      list.EnsureVisible(index,FALSE);
      list.SetItemState(index,LVIS_SELECTED,LVIS_SELECTED);
      list.SetFocus();
    }

  • 相关阅读:
    5.5团队冲刺08
    5.6团队冲刺09
    5.4团队冲刺07
    5.3团队冲刺06
    5.2团队冲刺05
    第14 周作业
    CentOS Linux release 7.4 yum 安装mariadb-5.5.65 登录报错 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/data/mysql/mysql.sock' (2)
    第13周作业
    解析函数
    npm模块安装机制
  • 原文地址:https://www.cnblogs.com/LJWJL/p/3725493.html
Copyright © 2011-2022 走看看