SandyB Posted November 4, 2003 Posted November 4, 2003 When I load my form, I can set the combobox to show a blank line by writing cbo1.SelectedIndex = -1 But when I need to re-initialize it to blank later, that same code doesn't work. Why not? And how can I set it to nothing again? I also tried cbo1.SelectedItem = Nothing Quote
Moderators Robby Posted November 4, 2003 Moderators Posted November 4, 2003 Try the Items.Clear() method. Quote Visit...Bassic Software
SandyB Posted November 4, 2003 Author Posted November 4, 2003 That doesn't work - I get the error message: Cannot modify the Items collection when the DataSource property is set. I have my controls bound to the data at design time,rather than in code. Do I need to unbind and rebind in the code? Quote
*Experts* jfackler Posted November 5, 2003 *Experts* Posted November 5, 2003 Change the dropdown style before you set the index to -1 and you'll get an empty combobox that is editible. cmbEmployeeName.DropDownStyle = ComboBoxStyle.DropDown cmbEmployeeName.SelectedIndex = -1 Jon Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.