In VB6 you could set the initial value held in ComboBox control to -1 so that it is blank to begin with. But in .NET if when the DataSource property is set for a ComboBox, you cannot modify the item collection. You cannot set ComboBox1.Text = "" or use Add method to add a new item to the list.
So how would you add a blank value to the ComboBox item collection, when it is bound to a data source?
The DataSource property of ComboBox accepts an object that implements the IList interface, such as a DataSet. Although you cannot modify the item collection, you can actually add a blank data row in DataSet which is bound to ComboBox. The new blank row will be shown in the ComboBox.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.