473,854 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

clearing a combo box...

I have something strange going on - pretty sure it used to work before - and
now it does not...

Why does the following code not clear a combo box?

Me.cboLocation. Text = String.Empty

OR

Me.cboLocation. Text = ""

Neither of the above works. The combo box contents remain exactly the same
after running that command...

Help!

Thanks, Brad
Jun 27 '08 #1
7 3588
On May 7, 1:17*pm, "Brad Pears" <br...@truenort hloghomes.comwr ote:
I have something strange going on - pretty sure it used to work before - and
now it does not...

Why does the following code not clear a combo box?

Me.cboLocation. Text = String.Empty

OR

Me.cboLocation. Text = ""

Neither of the above works. *The combo box contents remain exactly the same
after running that command...

Help!

Thanks, Brad
I think you will also need to set the .SelectedIndex property to -1.

At least, that works for me.
Jun 27 '08 #2
"Brad Pears" <br***@truenort hloghomes.comsc hrieb
I have something strange going on - pretty sure it used to work
before - and now it does not...

Why does the following code not clear a combo box?

Me.cboLocation. Text = String.Empty

OR

Me.cboLocation. Text = ""

Neither of the above works. The combo box contents remain exactly
the same after running that command...
What's the value of cboLocation.Dro pdownstyle? If it's "DropDownLi st",
use cboLocation.Sel ectedIndex = -1
Armin

Jun 27 '08 #3
On May 7, 8:17 pm, "Brad Pears" <br...@truenort hloghomes.comwr ote:
I have something strange going on - pretty sure it used to work before - and
now it does not...

Why does the following code not clear a combo box?

Me.cboLocation. Text = String.Empty

OR

Me.cboLocation. Text = ""

Neither of the above works. The combo box contents remain exactly the same
after running that command...

Help!

Thanks, Brad
Hi,
Using DropDownList style it doesn't clear combobox, Simple or DropDown
styles allow you to clear with the codes you've mentioned.

And if you want to clear current item of your combobox(curren t item,
because "clear" term may come to meaning of clearing entire combobox
which you did not intend to do), you can use
"Me.cboLocation .selectedindex = - 1" or add a empty item temporarily
using:

Me.cboLocation. Items.Add("")
Me.cboLocation. Text = ""
Me.cboLocation. Items.Remove("" )

Hope these help,

Onur
Jun 27 '08 #4
Thanks for your reply's... That works perfect.... I had changed the type of
drop down and that is why my previous code no longer worked. I knew there
had to be an explanation somewhere!!!

Thanks, again, Brad

"Brad Pears" <br***@truenort hloghomes.comwr ote in message
news:uK******** ******@TK2MSFTN GP02.phx.gbl...
>I have something strange going on - pretty sure it used to work before -
and now it does not...

Why does the following code not clear a combo box?

Me.cboLocation. Text = String.Empty

OR

Me.cboLocation. Text = ""

Neither of the above works. The combo box contents remain exactly the
same after running that command...

Help!

Thanks, Brad


Jun 27 '08 #5
I am trying to set a combo box's text property to a value from a listview
item's text property as shown below... However, it appears that because the
combo box is defined as a "DropDownLi st", am I am now unable to assign a
text value that way? Do I now have to find out what position the listview
item's text value I want is in the list of combo items and then assign an
index value instead of an actual text value? (Wow, that was a mouthful!!!)

Me.cboLabel.Tex t = Me.lvwJobPosts. SelectedItems.I tem(0).SubItems (2).Text
Thanks, Brad

"kimiraikko nen" <ki************ *@gmail.comwrot e in message
news:60******** *************** ***********@m44 g2000hsc.google groups.com...
On May 7, 8:17 pm, "Brad Pears" <br...@truenort hloghomes.comwr ote:
>I have something strange going on - pretty sure it used to work before -
and
now it does not...

Why does the following code not clear a combo box?

Me.cboLocation .Text = String.Empty

OR

Me.cboLocation .Text = ""

Neither of the above works. The combo box contents remain exactly the
same
after running that command...

Help!

Thanks, Brad

Hi,
Using DropDownList style it doesn't clear combobox, Simple or DropDown
styles allow you to clear with the codes you've mentioned.

And if you want to clear current item of your combobox(curren t item,
because "clear" term may come to meaning of clearing entire combobox
which you did not intend to do), you can use
"Me.cboLocation .selectedindex = - 1" or add a empty item temporarily
using:

Me.cboLocation. Items.Add("")
Me.cboLocation. Text = ""
Me.cboLocation. Items.Remove("" )

Hope these help,

Onur

Jun 27 '08 #6
On May 7, 11:20 pm, "Brad Pears" <br...@truenort hloghomes.comwr ote:
I am trying to set a combo box's text property to a value from a listview
item's text property as shown below... However, it appears that because the
combo box is defined as a "DropDownLi st", am I am now unable to assign a
text value that way? Do I now have to find out what position the listview
item's text value I want is in the list of combo items and then assign an
index value instead of an actual text value? (Wow, that was a mouthful!!!)

Me.cboLabel.Tex t = Me.lvwJobPosts. SelectedItems.I tem(0).SubItems (2).Text
Thanks, Brad

"kimiraikko nen" <kimiraikkone.. .@gmail.comwrot e in message

news:60******** *************** ***********@m44 g2000hsc.google groups.com...
On May 7, 8:17 pm, "Brad Pears" <br...@truenort hloghomes.comwr ote:
I have something strange going on - pretty sure it used to work before -
and
now it does not...
Why does the following code not clear a combo box?
Me.cboLocation. Text = String.Empty
OR
Me.cboLocation. Text = ""
Neither of the above works. The combo box contents remain exactly the
same
after running that command...
Help!
Thanks, Brad
Hi,
Using DropDownList style it doesn't clear combobox, Simple or DropDown
styles allow you to clear with the codes you've mentioned.
And if you want to clear current item of your combobox(curren t item,
because "clear" term may come to meaning of clearing entire combobox
which you did not intend to do), you can use
"Me.cboLocation .selectedindex = - 1" or add a empty item temporarily
using:
Me.cboLocation. Items.Add("")
Me.cboLocation. Text = ""
Me.cboLocation. Items.Remove("" )
Hope these help,
Onur
Hi,
I really had difficulty to make out what you're trying to do, as a
little understanding, if you want to syncronize two values between a
listview's subitem and combobox, you can do it with the code that you
posted.

Me.cboLabel.Tex t =
Me.lvwJobPosts. SelectedItems.I tem(0).SubItems (2).Text

I think you're asking if you have to specify index of listview
subitem's and i think yes you have to. If you used listbox instead of
listview you could use listbox1.select editem to get items text
property without specifying index (position) name.

Thanks,

Onur Güzel
Jun 27 '08 #7
Thanks for the reply... Yes, actually the code that I posted was actually
working as I discovered later on through more debugging. There was a
different problem that was setting the listview item index to -1 so it
appeared that my code was not setting the value at all when in fact it was.
Thanks for your help.

Brad
"kimiraikko nen" <ki************ *@gmail.comwrot e in message
news:99******** *************** ***********@e53 g2000hsa.google groups.com...
On May 7, 11:20 pm, "Brad Pears" <br...@truenort hloghomes.comwr ote:
I am trying to set a combo box's text property to a value from a listview
item's text property as shown below... However, it appears that because
the
combo box is defined as a "DropDownLi st", am I am now unable to assign a
text value that way? Do I now have to find out what position the listview
item's text value I want is in the list of combo items and then assign an
index value instead of an actual text value? (Wow, that was a mouthful!!!)

Me.cboLabel.Tex t = Me.lvwJobPosts. SelectedItems.I tem(0).SubItems (2).Text
Thanks, Brad

"kimiraikko nen" <kimiraikkone.. .@gmail.comwrot e in message

news:60******** *************** ***********@m44 g2000hsc.google groups.com...
On May 7, 8:17 pm, "Brad Pears" <br...@truenort hloghomes.comwr ote:
I have something strange going on - pretty sure it used to work
before -
and
now it does not...
Why does the following code not clear a combo box?
Me.cboLocation. Text = String.Empty
OR
Me.cboLocation. Text = ""
Neither of the above works. The combo box contents remain exactly the
same
after running that command...
Help!
Thanks, Brad
Hi,
Using DropDownList style it doesn't clear combobox, Simple or DropDown
styles allow you to clear with the codes you've mentioned.
And if you want to clear current item of your combobox(curren t item,
because "clear" term may come to meaning of clearing entire combobox
which you did not intend to do), you can use
"Me.cboLocation .selectedindex = - 1" or add a empty item temporarily
using:
Me.cboLocation. Items.Add("")
Me.cboLocation. Text = ""
Me.cboLocation. Items.Remove("" )
Hope these help,
Onur
Hi,
I really had difficulty to make out what you're trying to do, as a
little understanding, if you want to syncronize two values between a
listview's subitem and combobox, you can do it with the code that you
posted.

Me.cboLabel.Tex t =
Me.lvwJobPosts. SelectedItems.I tem(0).SubItems (2).Text

I think you're asking if you have to specify index of listview
subitem's and i think yes you have to. If you used listbox instead of
listview you could use listbox1.select editem to get items text
property without specifying index (position) name.

Thanks,

Onur Güzel
Jun 27 '08 #8

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

Similar topics

4
2121
by: Newbee | last post by:
Hola I wanted to kno how to clear the current text that is displayed in my combobox I am filling it with a query which is run against my database I have tried this but it not work Combobox1.text = " am i using the wrong event
3
392
by: Alex Wisnoski | last post by:
I have an edit record form with several text boxes, combo boxes, and check boxes. All of them are bound except for one combo box (cboPositionData), which I use to search for a specific record. I have a Clear button which I have coded to use the Me.undo if the form is dirty. I am testing for a situation in which the user would stop trying to enter data in cboPositionData and clear the form. When I enter a partial value in...
2
7971
by: Peter Bailey | last post by:
I have a function courtesy of the newsgroup that clears the list box. I would like to now set the listbox back to its initial state where you can see the first item in the list. The same goes for a combo box I am not sure after clearing how to get it back to show the first item. Regards Peter Function ClearList(lst As ListBox) As Boolean If lst.MultiSelect = 0 Then
3
3863
by: rmatteson | last post by:
I am trying to figure out how to clear all items from a combobox (Access 2002). On my form, I have to comboboxes. Combobox 2 is populated with a set of child data dependent on the parent data item selected in Combobox 1. This is done through the .AddItem method of Combobox 2 looping through the recordset. This works fine, until --> the data item in the Combobox 1 is changed, then Combobox 2 just appends the "new" related child data...
2
1457
by: Shannan Casteel via AccessMonster.com | last post by:
I have a table with information about different people...(i.e. Name, Address, Phone, Fax, etc.). The table has been linked to Access. I have created a combo box that uses this information. There are eight columns in the combo box, seven of which are hidden. Therefore upon a selection the information that was hidden is now displayed on some labels at the bottom of the page. I used code similar to the following to make this work: ...
2
2291
by: ed | last post by:
Hello- i'm having some problems getting innerhtml to clear on mozilla, but it works fine in ie. my page is setup such that i have a div: <div id="otherModel"></div> on a select from a combo box, in my javascript i execute: div = document.getElementById("otherModel"); depending on what's selected in a combobox, i execute:
5
2269
by: Geoff | last post by:
One of the entries in my subform is a field called . is populated by selecting from its drop down combo box which holds different text options I need to clear session if an invalid entry is made and I thought that the line
1
1755
by: Vayse | last post by:
I have a databound form, frmClients. One of the field is a combo box, comDepartment, which lets a user select a department for the Client. But I can't figure out how to clear the box. That is, sometimes a Client is dropped by a Department. How would a user clear the combo box so that no Department is selected? With the combo box dropdown style: Dropdown: User must pick from the list, so there is no way of clearing the box Dropdown List:...
2
1855
by: monikagovindaraj | last post by:
sir, I needed to clear the text boxvalue after refreshing the same page. actually im my program,the text box will be filled by using ajax.the value wil be assigned depends upon the previous combo box. after i refreshing the same page, the combo box refreshed, bt the text box hav the same value. i want to clear the text box value. help me
0
9899
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...
0
9750
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11023
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10672
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9509
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...
0
7076
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();...
0
5738
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4550
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
4147
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.