zoukankan      html  css  js  c++  java
  • FindStringExact

     
     
     

    Code::

    CComboBox::FindStringExact
    int FindStringExact( int nIndexStart, LPCTSTR lpszFind ) const;
    当nStartAfter=-1时,则表示查的整个列表框的的项目

     

    判断是否存在时用条件

      列表中有   字符串 str 返回值>= 0     
      列表中没有 字符串 str 返回值= -1       
     

       

    项目存在 不执行

        if (返回值>0 ) 项目存在;return;

        if (返回值!=-1 ) 项目存在;return;

     

    项目不存在 执行   

    if (返回值==-1 )

        {

            项目不存在;

        }

     
     
     

    Code::判断列表框中的项目是否已经存在了

    void CWwwDlg::OnButton1()
    {
        CString s;
        GetDlgItemText(IDC_COMBO1,s);
        int i = ((CComboBox*)GetDlgItem(IDC_COMBO1))->FindString(-1,s);
        CString s2;
        s2.Format("%d",i);
        MessageBox(s2);
    }

    效果图:

    这个问题需要解决

    a != aaaa

    完全相等才相等!

    如何处理

     

    Code:: FindStringExact可以解决FindString出现的问题

    void CWwwDlg::OnButton1() 
    {
        CString s;
        GetDlgItemText(IDC_COMBO1,s);
        if (s.IsEmpty()) return;
        int i = ((CComboBox*)GetDlgItem(IDC_COMBO1))->FindStringExact(-1,s);
        CString s2;
        s2.Format("%d",i);
        
        if (i>=0)
        {
            MessageBox("项目已存在!");
            return;
        }
        else
        {
            MessageBox("此项目不存在");
        }
        
    } 
      

    效果图:

     




  • 相关阅读:
    tomcat 虚拟目录
    linux 基本常用命令
    linux shell
    分布式锁
    多线程 ThreadLocal
    Java并发包中Lock的实现原理
    spring 异常处理
    spring Cache /Redis 缓存 + Spring 的集成示例
    spring 事务传播行为
    Vue.nextTick浅析
  • 原文地址:https://www.cnblogs.com/xe2011/p/3576988.html
Copyright © 2011-2022 走看看