Microsoft KB Archive/925730

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

Article ID: 925730

Article Last Modified on 12/3/2007

-

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 &quot;Applies to&quot; section.



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

Keywords: kbtshoot kbbug kbqfe kbpubtypekc kbhotfixserver KB925730

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.