Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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,

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...