Results 1 to 5 of 5

Thread: Help. Can't reset ComboBox to default text.

  1. #1

    Thread Starter
    Member Mugsy323's Avatar
    Join Date
    Oct 2014
    Posts
    51

    Question Help. Can't reset ComboBox to default text.

    I have a combo box on my form. The default text is "Select Type"

    One of my options is not yet supported, so I display a MsgBox and then try to reset the Combo back its default, but nothing I try works.
    Code:
    Private Sub cbxType_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbxType.SelectedIndexChanged        
            If cbxType.SelectedIndex = 0 Then
                MsgBox("Type is not yet supported.", MsgBoxStyle.Information + vbOKOnly)
                cbxType.ResetText()
                Exit Sub
            End If
            ...
    All this does is simply highlight the unwanted selection.

    I've also tried: cbxType.SelectedIndex = -1 and cbxType.SelectedText = "Select Type", but all they do is erase the combo box text, leaving it blank. ".ResetText()", ".SelectedItem = -1" & ".Refresh" all simply highlight the unwanted selection.

    What am I doing wrong? My guess is it's some sort of "recursive" issue, but I don't know where else to put the code. TIA

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,905

    Re: Help. Can't reset ComboBox to default text.

    Is the DropDownStyle set to DropDown or DropDownList?

  3. #3

    Thread Starter
    Member Mugsy323's Avatar
    Join Date
    Oct 2014
    Posts
    51

    Re: Help. Can't reset ComboBox to default text.

    Thx for the reply.

    The style is set to "DropDown" with displayed default text.

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,905

    Re: Help. Can't reset ComboBox to default text.

    Do you want the user to be able enter arbitrary text or do you just want them to be able to select from the drop-down list? If the latter, you probably ought to set the DropDownStyle to DropDownList. Do you really need "Select Type" displayed? I see a lot of people do this sort of thing but it seems like a "because I can" sort of thing. Do you place instructions in a TextBox to "Enter Type" or the like? Very few people do. If the user can work out how to use a TextBox, do you really think they need instructions on how to use a ComboBox?

  5. #5

    Thread Starter
    Member Mugsy323's Avatar
    Join Date
    Oct 2014
    Posts
    51

    Re: Help. Can't reset ComboBox to default text.

    Thx for the reply.

    I have a label beside the ComboBox, but a blank box with no text is not intuitive. It should at the very least show the first option. I don't need the user to be able to edit the text (only display the valid options in a drop-down.)

    A setting of "DropDownList" does not display any default text, and "Simple" appears to be no different than a textbox (no dropdown.)

    I don't understand why changing the ".Text" property in code doesn't change/display the default text.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width