Microsoft Knowledge Base Email Alertz

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

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 925730 - Last Review: October 8, 2011 - Revision: 2.0

BUG: A ComboBox control does not display any items in the .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;
			}
		}

APPLIES TO
  • Microsoft .NET Framework 2.0
Keywords: 
kbbug kbtshoot kbqfe KB925730
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate