You're welcome. Glad you got it working ! :-)
On Oct 29, 6:08 am, Benj Nunez <[EMAIL PROTECTED]> wrote:
> You're right! Hehe. Silly me. I figured this out a while back. Thanks
> again. :-)
>
> What I did then was to make a call to the Arraylist's Clear() method:
>
> displayList.Clear();
>
> It's working now.
>
> On Oct 28, 8:13 pm, Cerebrus <[EMAIL PROTECTED]> wrote:
>
>
>
> > ListBox.Items.Clear DOES remove all the items present in the ListBox.
> > I suspect that it is your ArrayList that still has the old items and
> > so they get added again.
>
> > On Oct 28, 1:05 pm, 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.- Hide quoted text -
>
> - Show quoted text -