How to clear combobox?

  • Thread starter Thread starter feng
  • Start date Start date
F

feng

In our VB.Net Windows form application we have a combobox
pre-populated with a list of items. What I need is simply
clear everything from it's dropdown, when a button is
clicked. I tried everything I can think of, such as set
data source to nothing, etc., but still not been able to
make it happen.

Can someone show me how to do it?

Thanks
 
Is it a data control?

If not, then call ComboBox1.Items.Clear

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
 
* "feng said:
In our VB.Net Windows form application we have a combobox
pre-populated with a list of items. What I need is simply
clear everything from it's dropdown, when a button is
clicked. I tried everything I can think of, such as set
data source to nothing, etc., but still not been able to
make it happen.

Are you using a databound control?

Try that:

\\\
Me.ComboBox1.Items.Clear()
///
 
Thanks for your reply.
The Comobox1.item.clear doesn't seem to work properly
since have datasource set - I am getting an error message
about this. When I try to set Comobox1.DataSource =
Nothing then I can clear the list, but I still have one
line displyed in the combo: System.Data.DataRowView. What
should I do with this?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top