Skip to Content
author's profile photo
Former Member

Clear value in a ombo box

Hi,

How can we clear the value in a combo box?

After adding values, I need to clear contents of all the items in my form.

But I am not able to do so for combo box.

I have tried the code

oForm.Items.Item("CmbClass").Specific.Selected.value =""

But It seems to give error.

There seems to be code for removing items in a combo.But do we have any code for clearing?

Mina

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    author's profile photo
    Former Member
    Aug 06, 2004 at 01:23 PM

    I usually clear them by including an extra valid value of "(None)" in the combo box and selecting it when clearing the form.

    John.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Aug 06, 2004 at 02:06 PM

    Maybe the foll. code is helpful.

    It runs thru the combo & initializes it.

    ========================================================

    If oCombo.ValidValues.Count > 0 Then

    iComboCnt = oCombo.ValidValues.Count

    For i = 0 To iComboCnt - 1

    oCombo.ValidValues.Remove 0, psk_Index

    Next i

    End If

    ========================================================

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      I recommend you clear the combo boxes by going "down" the list and then clearing the associated datasource like this:

      if (cmbBox.ValidValues.Count > 0)

      for (int i = cmbBox.ValidValues.Count; i <= cmbBox.ValidValues.Count; i--)

      cmbBox.ValidValues.Remove(i, BoSearchKey.psk_Index);

      DSCmbBox.Value = "";