Advertisement

02.09.2008 at 07:41AM PST, ID: 23150123
[x]
Attachment Details

How to reset combobox to default value after use

Asked by evanmarshall in Microsoft Visual Basic.Net, VB Controls

Tags:

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.Start Free Trial
[+][-]02.09.2008 at 07:45AM PST, ID: 20857602

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual Basic.Net, VB Controls
Tags: Visual Basic 2005
Sign Up Now!
Solution Provided By: inthecurve
Participating Experts: 2
Solution Grade: B
 
 
[+][-]02.09.2008 at 08:06AM PST, ID: 20857689

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628