谢谢!急!请局提出示一段源码!

解决方案 »

  1.   

    BOOL CDialog::OnInitDialog() 
    {
    // Be careful to call CDialog::OnInitDialog
    //  only once in this function
    CListBox* pLB = (CListBox*) GetDlgItem(IDC_DEPT);
    pLB->InsertString(-1, "Documentation");
    pLB->InsertString(-1, "Accounting");
    pLB->InsertString(-1, "Human Relations");
    pLB->InsertString(-1, "Security");
            
             return CDialog::OnInitDialog();
    }
    重载OnInitDialog()函数,IDC_DEPT是listbox对话框的id
      

  2.   

    AddString(...)在ListBox中添加数据
      

  3.   

    // The pointer to my list box.
    extern CListBox* pmyListBox;// Add 10 items to the list box.
    CString str;
    for (int i=0;i < 10;i++)
    {
       str.Format(_T("item string %d"), i);
       pmyListBox->AddString( str );
    }
      

  4.   

    AddString(你要的字符串)
    也可以用InsertString(索引,你要的字符串)