Shaitan00 Posted September 5, 2005 Posted September 5, 2005 Given a Combobox [cbClient] that has been populated by a DataSet [ds] as such: cbClient.DataSource = ds.Tables[0]; cbClient.DisplayMember = "CLIENTS"; cbClient.ValueMember = "CLIENTS"; cbClient.SelectedIndex = -1; Problem is I can't seem to find a way to CLEAR/EMPTY the combobox when I want to, meaning if the user presses the "CLEAR" button I want the combobox [cbClient] to become empty. I tried stuff like "cbClient.Items.Clear()" but that gave errors like "Cannot modify the items collection when the DataSource property is set", I then tried using stuff like "cbClient.DataSource = null" but that does something really odd to the GUI of the Combobox (looks like the app crashed) and stuff like .Dispose() doesn't seem to work. Some have hinted that I need to edit the DATASOURCE (dataset ds) itself, I don't want to do it (seeing as I reuse it) I just want to clear the combobox so the user doesn't see anything in it at thay moment, maybe in the future I will rebind it :) Any hints/Help/Clues would be much appreciated. Thanks, Quote
Machaira Posted September 6, 2005 Posted September 6, 2005 Doing comboBox1.DataSource = null; works fine for me. Quote Here's what I'm up to.
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.