473,943 Members | 6,128 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 59483
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*******@disc ussions.microso ft.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*******@disc ussions.microso ft.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.It ems.Clear()
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
Thanks for your reply.
The Comobox1.item.c lear doesn't seem to work properly
since have datasource set - I am getting an error message
about this. When I try to set Comobox1.DataSo urce =
Nothing then I can clear the list, but I still have one
line displyed in the combo: System.Data.Dat aRowView. What
should I do with this?

Thanks
-----Original Message-----
* "feng" <an*******@disc ussions.microso ft.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.I tems.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*******@disc ussions.microso ft.com> wrote in message
news:39******** *************** *****@phx.gbl.. .
Thanks for your reply.
The Comobox1.item.c lear doesn't seem to work properly
since have datasource set - I am getting an error message
about this. When I try to set Comobox1.DataSo urce =
Nothing then I can clear the list, but I still have one
line displyed in the combo: System.Data.Dat aRowView. What
should I do with this?

Thanks
-----Original Message-----
* "feng" <an*******@disc ussions.microso ft.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.I tems.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*******@disc ussions.microso ft.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
630
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 otehr box. I want to make a selection in the app combobox, update the second box and when I select a new app, it should remove all items in teh 2nd combobox and refresh the list with only the selected app. With this code it appears the binding is...
4
2744
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=""; autoCompleteComboBox2.Text=""; autoCompleteComboBox2.SelectedText=""; autoCompleteComboBox3.Text="";
1
4565
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 can't seem to catch any events that would indicate when this is happening. I've tried SelectedIndexChanged, SelectedValueChanged, TextChanged. What can I do to know when the user calls Clear() on the ComboBox items list? This is .NET v1.1. --
1
1533
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 would. I've placed break points in the following events and still they are not triggered: Click SelectedValueChange
13
29240
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 if I can use the same way in VB.Net. If I can't use With statement in VB.Net, what should I do? Thanks!!
3
18036
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 combobox. My problem is that when I try to clear the ComboBox it clears the items that were inserted into the ComboBox, but does not clear the item I selected in the ComboBox... For Instance.
0
2260
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 2. But on the next row, when I leave Column 1 blank and click on Column 2, it generates error DataGridViewComboBoxCell value is invalid. And the code below works fine the first time I click Column 2, leaving Column 1 blank. I just want to...
1
60922
by: Minou | last post by:
How to clear a combobox in VBA?
5
10860
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 function may be called from the combobox after_update event or a "clear filter" buttons after_update event. I placed this in a module. Oh, one more thing... I happened to have my FK in column 1 of the combobox, this may need changed. Sorry if I...
0
10135
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
11299
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10662
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9865
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8219
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4910
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.