473,406 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to clear combobox?

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

Nov 20 '05 #1
5 59405
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" <an*******@discussions.microsoft.com> wrote in message
news:39****************************@phx.gbl...
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

Nov 20 '05 #2
* "feng" <an*******@discussions.microsoft.com> scripsit:
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()
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
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
-----Original Message-----
* "feng" <an*******@discussions.microsoft.com> scripsit:
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()
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
.

Nov 20 '05 #4
You have to set the data source = nothing
before issuing ..items.clear

jc

"feng" <an*******@discussions.microsoft.com> wrote in message
news:39****************************@phx.gbl...
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
-----Original Message-----
* "feng" <an*******@discussions.microsoft.com> scripsit:
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()
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
.

Nov 20 '05 #5
Have you tried calling DataTable.Clear on the table that it's bound to?
"feng" <an*******@discussions.microsoft.com> wrote in message
news:39****************************@phx.gbl...
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

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: stingrays | last post by:
Below is my code for a combobox. Basically, I have 2 comboboxes. 1 box is the application selection and the other retrieves data from the dataset (SQL Server) to populate the drop down in the...
4
by: Keith Smith | last post by:
Is there an easier way to clear all of the comboBoxes on my form? I am currently using this code... autoCompleteComboBox1.Text=""; autoCompleteComboBox1.SelectedText=""; ...
1
by: mdb | last post by:
I currently catch the SelectedIndexChanged event on a ComboBox to perform some processing when the user changes the selected item. But I also want to know when the user clears the list, but I...
1
by: Rob R. Ainscough | last post by:
What I'm trying to accomplish is: Disable a ComboBox (not bound to any data) when a .Clear method is executed. So far a cboComboBox.Items.Clear does NOT trigger any of the events I expected it...
13
by: KKuser | last post by:
Hello: I have 20, 30 text and combo boxes on one form, and I would like to clear them up at one time using the statement "With..........End With". I used this when using VB6, but I don't know...
3
by: samoore33 | last post by:
I am populating a ComboBox at run time. I insert the first value of "Choose Value" cboTaxValue.Item.Insert(0, "Choose Value") Then I loop through the rest of the values to be added to the...
0
by: sixths3ns3 | last post by:
My DataGridView has two columns. Combobox Column 2 displays list based on Combobox Column 1 selected value. The code below works fine when I select a value on Column 1, and select a value on Column...
1
by: Minou | last post by:
How to clear a combobox in VBA?
5
aas4mis
by: aas4mis | last post by:
I haven't had much luck with specific controls, their properties and loops in the past. I thought I would share this tidbit of code, feel free to modify/modularize in any way to suit your needs. This...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.