Benj Nunez
unread,Oct 28, 2008, 4:05:56 AM10/28/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
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.