Link to home
Start Free TrialLog in
Avatar of evanmarshall
evanmarshallFlag for Afghanistan

asked on

How to reset combobox to default value after use

I have a combobox that is populated with items according to the user's input. The combobox's default text is "Select Section Character." My problem is that after the user has made a selection, the combobox does not reset to display "Select Section Character" for the next use. Instead, it still displays the user's previous selection. I have tried everything but can't get it to work.

Here is my code that populates the combobox:

Private Sub btnWordLengthSubmit_Click(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles btnWordLengthSubmit.Click

cboSelectSectionCharacter.Items.Clear()
        cboSelectSectionCharacter.Items.Add(strLeadName)
        cboSelectSectionCharacter.Text = "Select Section Character"

        Select Case dblWordLength
            Case 50000 To 64000
                cboSelectSectionCharacter.Items.Add(strVP2)
            Case 65000 To 89000
                cboSelectSectionCharacter.Items.Add(strVP2)
                cboSelectSectionCharacter.Items.Add(strVP3)
            Case 90000 To 114000
                cboSelectSectionCharacter.Items.Add(strVP2)
                cboSelectSectionCharacter.Items.Add(strVP3)
                cboSelectSectionCharacter.Items.Add(strVP4)
            Case 115000 To 139000
                cboSelectSectionCharacter.Items.Add(strVP2)
                cboSelectSectionCharacter.Items.Add(strVP3)
                cboSelectSectionCharacter.Items.Add(strVP4)
                cboSelectSectionCharacter.Items.Add(strVP5)
            Case 140000 To 154000
                cboSelectSectionCharacter.Items.Add(strVP2)
                cboSelectSectionCharacter.Items.Add(strVP3)
                cboSelectSectionCharacter.Items.Add(strVP4)
                cboSelectSectionCharacter.Items.Add(strVP5)
                cboSelectSectionCharacter.Items.Add(strVP6)
        End Select


And here is the code for when the user makes a selection in the combobox:


    Private Sub cboSelectSectionCharacter_SelectedIndexChanged(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles cboSelectSectionCharacter.SelectedIndexChanged

        Dim strNodeName As String = treNovelStructure.SelectedNode.Name
        Select Case strNodeName
            Case "8"
                strVPCharacterOfSection8 = cboSelectSectionCharacter.SelectedItem
                txtSectionCharacter.Text = strVPCharacterOfSection8
                DrawTree()
                Dim node() As TreeNode = treNovelStructure.Nodes.Find("8", True)
                If Not node.Length = 0 Then
                    treNovelStructure.SelectedNode = node(0)
                End If
                treNovelStructure.Focus()
                treNovelStructure.SelectedNode.BackColor = Color.MidnightBlue
...
End Select
    End Sub

I also have the combobox's text property set to "Select Section Character."

What am I doing wrong/not doing? Any help will be greatly appreciated. Many thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of inthecurve
inthecurve
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial