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("此项目不存在");
}
} 效果图: |
FindStringExact的更多相关文章
- C#常用控件介绍
目录 1.窗体(Form) 2.Label (标签)控件 3.TextBox(文本框)控件 4.RichTe ...
- winFrom 常用控件属性及方法介绍
目录 1.窗体(Form) 2.Label (标签)控件 3.TextBox(文本框)控件 4.RichTextBox控件 5.NumericUpDown控件 6.Button(按钮)控件 7.Gro ...
- C#控件及常用设计整
C#控件及常用设计整 1.窗体 1 2.Label 控件 3 3.TextBox 控件 4 4.RichTextBox控件 5 5.NumericUpDown 控件 7 ...
- MFCC常用类介绍
http://www.cnblogs.com/lzmfywz/archive/2012/04/22/2465069.html CStatic CObject └CCmdTarget └CWnd └CS ...
- MFC ComboBox的使用
前言 Combo Box (组合框)控件很简单,可以节省空间.从用户角度来看,这个控件是由一个文本输入控件和一个下拉菜单组成的.用户可以从一个预先定义的列表里选择一个选项,同时也可以直接在文本框里面输 ...
- C# 常用控件及单击事件
1.窗体 1.常用属性 (1)Name属性:用来获取或设置窗体的名称,在应用程序中可通过Name属性来引用窗体. (2)WindowState属性: 用来获取或设置窗体的窗口状态. 取值有三种: No ...
- C# Windows - ListBox&CheckedListBox
ListBox和CheckedListBox类的属性 属性 说明 SelectedIndex 这个值表明列表框中选中项的基于0的索引 ColumnWidth 在包含多个列的列表框中,这个属性指定列宽 ...
- MFC下拉框使用方法
Combo Box (组合框)控件很简单,可以节省空间.从用户角度来看,这个控件是由一个文本输入控件和一个下拉菜单组成的.用户可以从一个预先定义的列表里选择一个选项,同时也可以直接在文本框里面输入文本 ...
- ListBox基础
关键点 在列表框生成后需要向其中加入或是删除行,可以利用: int AddString( LPCTSTR lpszItem )添加行, int DeleteString( UINT nIndex ...
随机推荐
- nginx Location配置总结(转)
本文部分转自:http://cssor.com/nginx-location-configuration.html 一. 开头 语法规则: location [=|~|~*|^~] /uri/ { … ...
- 使用NSURLSession实现断点续传
在sb中创建按钮,并且连线到.m文件中
- [wikioi]二叉树最大宽度和高度
简单的DFS,用数组w记录每一层的宽度就行了,就是遇到一层就++.中间发现在C++里面,如果int未初始化就是用也是有异常的.还有二叉树的数组表示时,从1开始计数会比较好.还有后来学会了数组这样的初始 ...
- java1.8的几大新特性(一)
一.接口的默认方法与静态方法,也就是接口中可以有实现方法 public class Test { public static void main(String[] args) { Formula a= ...
- MyBatis学习总结1
MyBatis是一个支持普通SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis消除了几乎所有的JDBC代码和参数的手工设置以及对结果集的检索封装.MyBatis可以使用简单的XML或注解用 ...
- USACO3.25Magic Squares(bfs)
/* ID: shangca2 LANG: C++ TASK: msquare */ #include <iostream> #include<cstdio> #include ...
- Google Chrome中的高性能网络(一)
以下内容是"The Performance of Open Source Applications" (POSA)的草稿, 也是The Architecture of Open S ...
- rfc all download
http://www.rfc-editor.org/download.html about RTSP http://en.wikipedia.org/wiki/Real_Time_Streaming_ ...
- How to change the property of a control from a flowlayoutpanel?
Well, the easiest way would be to retain an explicit reference to the buttons you're adding. Otherwi ...
- Entity Framework Linq 简单笔记
类型查询 public class bbb:xxx {} var items = from c in context.Dbset<xxx> where c is bbb sele ...

