I have a ComboBox (Windows Forms) related to a List. It is created during development. When the contents of the list change, my code calls a function to update the data binding. This works fine for .NET 3.5 :
BindingData.SuspendBinding();
DataSource = null;
DataSource = BindingData;
BindingData.ResumeBinding();
I switched to .NET 4.0 and it stops working . In particular, after passing this code, the VS debugger shows BindingData.DataSource refers to a list of 127 items, but the ComboBox Items property contains zero items.
See this SO question on a similar topic: The number of ComboBox elements does not match the DataSource .
I tried everything I could think of. Currently my code is as follows and still not working:
BindingData.SuspendBinding();
DataSource = null;
DataSource = BindingData;
BindingData.ResumeBinding();
BindingContext Dummy = this.BindingContext;
Invalidate();
PerformLayout();
List BindingList, . .NET 3.5 .NET 4.0 , . , , . ?
ComboBox:
private BindingSource BindingData = new BindingSource();
BindingData.DataSource = Nodes;
DataSource = BindingData;
,