如何清空一个ListBox中的内容(CListBox*)GetDlgItem(IDC_LIST1)->ResetContent();
网上说的这个方法根本不对,没有对应的方法!!!请教方法???备注:(CListBox*)GetDlgItem(IDC_LIST1)->GetCount()也没有!!!

解决方案 »

  1.   

    CListBox *pListBox = static_cast<CListBox *>(GetDlgItem(IDC_LIST1));
    while(pListBox->GetCount()>0)   
    {   
       pListBox->DeleteString(0);   
    }
    试试这个
      

  2.   

    如果是全部清空的话就是((CListBox*)GetDlgItem(IDC_LIST1))->ResetContent(); 如果是只清空一个的话就是((CListBox*)GetDlgItem(IDC_LIST1))->DeleteString(那一项的索引); 
      

  3.   

    (CListBox*)GetDlgItem(IDC_LIST1)->ResetContent(); 
    应该是
    ((CListBox*)GetDlgItem(IDC_LIST1))->ResetContent(); 
    你的强制转换后才能使用,实际你的还没转换,所以没发用
      

  4.   

    有个简单但效率低的办法。getcount();得到字符串数目。然后采用循环逐条删除。
      

  5.   

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ((CListBox*)GetDlgItem(IDC_LIST1))->GetCount()
    楼主要认真啊,差之毫厘谬之千里啊!
      

  6.   

    if ((CListBox*)GetDlgItem(IDC_LIST1))->GetCount() > 0)
    {
        ((CListBox*)GetDlgItem(IDC_LIST1))->ResetContent();
    }
      

  7.   

    这件将ListBox关联一个变量,m_listbox再用m_listbox.ResetContent()就行了啊
      

  8.   

    一,((CListBox*)GetDlgItem(IDC_LIST1))->ResetContent();
    二,CListBox *plb = ,(CListBox*)GetDlgItem(IDC_LIST1);
        for(int i = 0; i < plb->GetCounts; i++)
            plb->DeleteSring(i);