int[] arr = int[100];
listBox1.DataSource = arr;
void ComboBox1SelectedIndexChanged(object sender, EventArgs e)
{
.....//some processes
listBox1.DataSource =
The problem might come from the ListBox SelectionMode.
For a reason that I don't know, the databinding does not work when SelectionMode is SelectionMode.None.
A workaround could be:
listBox.SelectionMode = SelectionMode.MultiExtended;
listBox.DataSource = myDatasource;
listBox.SelectionMode = SelectionMode.None;
Hope it helps.
try the following
listBox1.DataBind()
Use BeginUpdate and EndUpdate, that should solve it. No need to set the data source twice
listBox1.BeginUpdate();
listBox1.DataSource = myList;
listBox1.EndUpdate();
my first answer on stack exchange here.
C# .Net 4.0:
listBox1.DataSource = null;
listBox1.DataSource = names;
I noticed that setting the datasource for the first time, it refreshes. When it's set, and you try set it to the same one again, it doesn't update.
So I made it null, set it to the same one, and it displayed correctly for me with this issue.