I've setup the simplest of tests; A form with a ListBox and a Button. The
ListBox is bound to a List<string>. When you click the Button, a new string
is added to the list.
I can't for the life of me get the ListBox to update when new items are
added to it's DataSource!
<code>
List<stringdateTimeStringList = new List<string>();
private void button1_Click(object sender, EventArgs e)
{
if(listBox1.DataSource == null)
{
listBox1.DataSource = dateTimeStringList;
}
dateTimeStringList.Add(DateTime.Now.ToString());
}
</code>
The only way I have been able to get it to work is to set the DataSource =
null, then set it back to the List<string>
Am I expecting it to do something it shouldn't? Currently it seems as
though all it does is populate the list - there is no persistent link with
the source data.
I must be doing this very wrong?
Thanks for any suggestions or help,
Steve