[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

VB .NET resetting a combo box

I have a form where the user will choose 1 of 2 options, by radio button.
When button 1 (rbVar1byValue) is clicked, a combo box is enabled and populated.  The options under button 2 are disabled.  (this works correctly)
When button 2 (rbVar1byName) is clicked, a text box is enabled for data entry. (this also works correctly)

If button 1 is clicked then the user changes their mind and clicks button 2, I want the combo box reset (to blank) without having to repopulate the combo box.

The current entries in the combo box are:
blank
Color
Type
Count

Here's what I have for CheckedChanged:
-----------------------------------
Private Sub rbVar1byValue_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbVar1byValue.CheckedChanged

        If rbVar1byValue.Checked = True Then
            cmbBx1ValueField.SelectedText = ""
            dfBx1ValueFieldsFound.Text = ""
            cmbBx1ValueField.Enabled = True
            cmbBx1ValueFieldValues.Enabled = True
            cmbBx1ValueExpr.Enabled = True

            dfPrefix1NmFieldsFound.Text = ""
            dfBx1NmFieldsFound.Text = ""
            dfPrefix1NmFieldsFound.Enabled = False

            dfOutputNm1.Enabled = True
            cmbBx1ValueField.Focus()

        End If
End Sub
 
Private Sub rbVar1byName_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbVar1byName.CheckedChanged

        If rbVar1byName.Checked = True Then
            cmbBx1ValueField.Text = ""
            cmbBx1ValueField.Enabled = False
            dfBx1ValueFieldsFound.Text = ""
            cmbBx1ValueFieldValues.Enabled = False
            cmbBx1ValueExpr.Enabled = False

            dfPrefix1NmFieldsFound.Text = ""
            dfPrefix1NmFieldsFound.Enabled = True
            dfBx1NmFieldsFound.Text = ""

            dfOutputNm1.Enabled = True
            dfPrefix1NmFieldsFound.Focus()

        End If
End Sub
--------------------------------
There is obviously something I do not understand on combo boxes.

Thanks in advance for help!
0
kkbenj
Asked:
kkbenj
  • 2
  • 2
  • 2
1 Solution
 
me655321Commented:
To reset a combobox you just do:
        cmbBx1ValueField.Items.Clear()
0
 
kkbenjAuthor Commented:
I do not want to clear out the values, just set the selected to the blank, leaving all values available for selection later.
0
 
me655321Commented:
Oh ok, then you just want to do:
        cmbBx1ValueField.SelectedIndex = -1
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
silemoneCommented:
if there's one, try the refresh() method...
0
 
silemoneCommented:
if its a blank inside of the combo box, doesn't the index = 0....
0
 
kkbenjAuthor Commented:
SelectedIndex = -1 did the trick.

Thanks.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now