The problem is that You can not change data source of sorted combobox.
Here is excerpt of the code of ComboBox control:
protected override void OnDataSourceChanged(EventArgs e)
{
if ((this.Sorted && (this.DataSource != null)) && base.Created)
{
this.DataSource = null;
throw new InvalidOperationException(System.Windows.Forms.SR.GetString("ComboBoxDataSourceWithSort"));
}
...
...
}
In such case You should have received an InvalidOperationException.
Why didn't You receive ?
Here is the answer:
Implementation of DataSource property in ComboBox control redirects to its base class (ListControl) implementation:
public object DataSource
{
get
{
return base.DataSource;
}
set
{
base.DataSource = value;
}
}
And then in the base class's DataSource:
public object DataSource
{
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
get
{
return this.dataSource;
}
set
{
if (((value != null) && !(value is IList)) && !(value is IListSource))
{
throw new ArgumentException(System.Windows.Forms.SR.GetString("BadDataSourceForComplexBinding"));
}
if (this.dataSource != value)
{
try
{
this.SetDataConnection(value, this.displayMember, false);
}
catch
{
this.DisplayMember = "";
}
if (value == null)
{
this.DisplayMember = "";
}
}
}
}
Please, pay attention to the silent catch block.
Since SetDataConnection calls OnDataSourceChanged then as far as my analysis is correct this is the reason. If I'm wrong, please correct me.