locked
initialising the list box RRS feed

  • Question

  • Hello everyone.

    Could anyone please tell me how to initialise a list box ?  I have a List button that makes a list box show a list of existing folders of a person's e-mail account and it works fine.  But when I click on the button a second time, it adds the same list at the bottom...

    What I want to happen is that everytime I click on the button, the box is re-initialised or its contents are just emptied.

    Here's what I do to generate the list where m_LISTBOX1 is the member variable that's a control type:

    Cnt = 0;
                while (Cnt != 20)//(Array[Ctr] != "")
                {
                    m_LISTBOX1.InsertString(Cnt,Array[Cnt]);
                    Cnt+=1;
                }

    Here's my first try to initialise the box but it didn't work, it just adds the list at the bottom.

    int Cnt = 0;
                /*//to initialize the box
                while (Cnt != 20)
                {
                    m_LISTBOX1.DeleteString(Cnt);
                    Cnt+=1;
                }*/

    Here's my second try using a string member variable named m_LISTSTRING:

    m_LISTSTRING.Empty();Can

    Can anyone help me on this please ??? Thanks a bunch !

    Tuesday, November 11, 2008 6:54 PM

Answers

  •  

    Code Snippet

    m_LISTBOX1.ResetContent();

     

     

    Tuesday, November 11, 2008 8:10 PM

All replies

  •  

    Code Snippet

    m_LISTBOX1.ResetContent();

     

     

    Tuesday, November 11, 2008 8:10 PM
  • Hey saju !

    Thanks a lot... I didn't even see that.  It wasn't on the CString methods on MSDN when I checked it... Maybe I wasn't looking at the right place.

    Thanks yet again !

    Cheers
    Tuesday, November 11, 2008 8:23 PM