Have you considered just binding the listbox to your arraylist?

On Tue, Oct 28, 2008 at 4:05 AM, Benj Nunez <[EMAIL PROTECTED]> wrote:

>
> Normally, in other languages like Delphi, I used to clear the contents
> of the Listbox
> before I fill it up with data. My C# code looks like this:
>
>        private void btnCheck_Click(object sender, EventArgs e)
>        {
>            listBox.Items.Clear();
>
>            foreach (string s in displayList)
>            {
>                listBox.Items.Add(s);
>            }
>        }
>
> I noticed that whenever you enter values to the Listbox, instead of
> removing the previous entries,
> the succeeding values only gets appended. For example, on the first
> pass I enter "abc", the output
> is "abc". On the second pass, I enter "123", the values will now be
> "abc" and "123" one for each line!
>
> Is there a workaround on this? How do I clear the contents of the
> Listbox? By the way I use Arraylist to store data prior to displaying
> it to the Listbox.
>
>
>
>
>
>
>
>


-- 
_______________________________

Take care,
Paul

It is not we non-interventionists who are isolationists. The real
isolationists are those who impose sanctions and embargos on countries and
peoples across the globe and who choose to use force overseas to promote
democracy. A counterproductive approach that actually leads the U.S. to be
more resented and more isolated in the world.

Dr. Ron Paul

www.RonPaul2008.com

Reply via email to