Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reset a Combobox

Status
Not open for further replies.

Collin79

Programmer
Dec 31, 2000
31
MX
Hi Again:

How can I do to reset a combobox to its default value, I've done a command button "new" that reset all the values on my form, but in that combobox still only the selected value (idkey that I choosed)

 
I'm just finishing my third beer, so maybe this answer is not so coherent...

Say, you've opted for the following construction:
Code:
cmdNew.Click
THISFORM.Reset()

METHOD Reset (on the form)
cboChoice.VALUE = <default value>
(..)

A more structured approach:
create an object cCombo based on the combobox
Add a method Reset()
Code:
Code:
LPARAMETERS tuValue
THIS.VALUE = tuValue

Now, following the same example as above:
Code:
cmdNew.Click
THISFORM.Reset()

METHOD Reset (on the form)
cboChoice.Reset( <default value> )
(..)

Ok, that's the general idea. If you're combo box has a control source set, the following also works; given the same example and given that the control source is set to THISFORM.cboValue:
Code:
cmdNew.Click
THISFORM.Reset()

METHOD Reset (on the form)
THIS.cboValue = <default value>
cboChoice.REFRESH()
(..)

The answer you probably need:
If using a controlsource; reset the controlsource value AND refresh the combobox
('cause of them beers, I did check; works fine)
Diederik Vermeeren
verm1864@exact.nl
 
Hi Collin79,

Depends on what you mean by 'default value'.

If you mean resetting it to no items selected, use MyComboBox.ListIndex = 0. Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top