Databound listbox refresh problem

T

Tariq

Hi,

I have a list box that is bound to an arraylist, but when the data
changes the listbox does not refresh.

-----------------------------------------------------------------------------
al = new ArrayList();
al.Add("1");al.Add("2");al.Add("3");al.Add("4");al.Add("5");al.Add("6");
listBox1.DataSource = al;
label1.Text = al.Count.ToString();
----
Data source changes
private void button1_Click(object sender, System.EventArgs e)
{
al.Remove(listBox1.SelectedItem.ToString());
label1.Text = al.Count.ToString();
listBox1.Update();
}
-----------------------------------------------------------------------------

Unfortunately I have to resort to setting listbox.DataSource = null;
and listbox.DataSource = al; for the listbox to refresh.

Am I missing something|?

- Tariq
 
V

V&G

It's seems as you on the right way.
I saw some examples by Rockford Lhotka - he sugested the same way.

If you have blinking effects try to use SuspendLayout / ResumeLayout
functions
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top