BUG: A ComboBox control does not display any items in the .NET Framework 2.0 (925730)



The information in this article applies to:

  • Microsoft .NET Framework 2.0

SYMPTOMS

When you bind a ComboBox control to an array, the ComboBox control does not display any items. Additionally, the Microsoft .NET Framework 2.0 does not throw an exception as expected.

This problem occurs if the following conditions are true:
  • The data source of the ComboBox control is set to use an array.
  • The Sorted property of the ComboBox control is set to true.

CAUSE

This problem occurs because of a bug in the .NET Framework 2.0. You cannot sort a ComboBox control that uses an array as a data source.

WORKAROUND

To work around this problem, sort the array first. Then bind the array to the ComboBox control.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

When you run the following code, you experience the problem that is described in the "Symptoms" section.
private void button1_Click(object sender, System.EventArgs e)
		{
			string [] myArray = new string[3] {"item1", "item2","item3"};
			comboBox1.Sorted=true;
			comboBox1.DataSource = myArray;
			if ( comboBox1.Items.Count > 0 )
			{
				comboBox1.SelectedIndex = 0;
			}
		}

Modification Type:MajorLast Reviewed:9/28/2006
Keywords:kbBug kbtshoot kbQFE kbhotfixserver kbpubtypekc KB925730 kbAudITPRO kbAudDeveloper