mfc CCombox系统定义成员函数

通过ID操作对象
CComboBox(组合框)控件
CComboBox类常用成员
CComboBox插入数据
CComboBox删除数据
CComboBox运用示例

一、CComboBox控件常用属性
   Disabled
   Visible
   type
   数据

二、CComboBox类常用成员

((CComboBox*)GetDlgItem(IDC_COMBO1))//获取组合框对象指针,这样可以不关联控件变量,也可以操作组合框对象

CComboBox::ResetContent//清空组合框内容
void ResetContent( );

CComboBox::AddString//添加lpszString 至组合框尾部
int AddString( LPCTSTR lpszString );

CComboBox::DeleteString//删除nIndex行
int DeleteString( UINT nIndex );

CComboBox::InsertString //在nIndex行后,插入行
int InsertString( int nIndex, LPCTSTR lpszString );

CComboBox::SelectString //可以选中包含指定字符串的行
int SelectString( int nStartAfter, LPCTSTR lpszString );

CComboBox::FindString //可以在当前所有行中查找指定的字符传的位置,nStartAfter指明从那一行开始进行查找。 
int FindString( int nStartAfter, LPCTSTR lpszString ) const;

CComboBox::GetCount //获取行数
int GetCount( ) const;

CComboBox::GetCurSel//获取当前选中行的行号
int GetCurSel( ) const;

CComboBox::SetCurSel(n)//设置第n行内容为显示的内容
int SetCurSel( int nSelect );

CComboBox::GetLBText (n,str)//获取第n行的内容 保存至str 
int GetLBText( int nIndex, LPTSTR lpszText ) const;
void GetLBText( int nIndex, CString& rString ) const;


GetWindowText//获取显示内容

三、代码示例
  TCHAR ws[256];
    CComboBox* pcombo=(CComboBox*)GetDlgItem(IDC_COMBO1);
 //   ((CComboBox*)GetDlgItem(IDC_COMBO1))->GetWindowText(ws,256);
    //((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString(ws);
    pcombo->GetLBText(2,ws);
    TRACE("---------%S\n",ws);
    int pos=pcombo->GetCurSel();
    pcombo->SetCurSel(2);
    switch(pos)
    {
    case 0:
        break;
    case 1:
        break;
    default:
        break;
    }

 

转载于:https://www.cnblogs.com/whzym111/p/6213965.html

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值