C++ CheckListBox

 

 

实现过程


    CCheckListBox    listbox1;

 

    listbox1.AddString("葡萄");
    listbox1.AddString("苹果");

    listbox1.AddString("桔子");

//判断你选择了哪些项目

void CCheckListBoxDlg::OnButtonOk() 
{
    // TODO: Add your control notification handler code here
    CString strTextstrItem;
    int nSelCount = 0i = 0;
    
    strText = "您已经选择了:";
    int nCount = listbox1.GetCount();
    for(i = 0i < nCounti++)
    {
        if(listbox1.GetCheck(i))
        {
            nSelCount++;
        }
    }
    if(nSelCount <= 0)
    {
        AfxMessageBox("请选择一种水果。");
        return;
    }
    int nStep = 0;
    for(i = 0i < nCounti++)
    {
        if(listbox1.GetCheck(i))
        {
            listbox1.GetText(istrItem);
            strText += strItem;
            nStep++;
            if(nStep == nSelCount)
            {
                strText += "。";
            }
            else
            {
                strText += ",";
            }
        }
    }
    AfxMessageBox(strText);
}

 

 


备注

 

关键点

 

相关链接

相关链接    相关链接

相关链接    相关链接

 




附件列表

     

    posted @ 2014-03-21 14:04  XE2011  阅读(447)  评论(0编辑  收藏  举报