Drop-down list combobox issues

lkritchey

Member
Joined
Sep 26, 2008
Messages
8
Location
Mechanicsburg, PA
Programming Experience
1-3
I have created a drop-down list box that holds 8 numbers representing a month span (3, 6, 9, 12, 15, 18, 21, 25 months). In order to prevent users from typing just anything into the text box above the combo box, I changed it to a drop-down listbox. The other requirement that I was hoping to implement was for the user to be able to type a number, after which the selection would jump to the appropriate item (i.e. the user types in '1', and the selection jumps to 12). This partially works. It will jump to 12, for example, but immediately after the user types the '1', the Selected Index event changes. The user cannot scroll down or up after typing in a number.

I did this same thing with another drop-down listbox, which held months (Jan 07, Feb 07, Mar 07, etc.). Ironically, this listbox works exactly like I want it to. It will jump down to the appropriate month based on what the user types, and will let the user use the keyboard up and down to change the selection.

Have any of you experienced this? Would the difference be because of the user typing in numbers instead of alpha characters? The properties between the two controls are identical, so I am confused by the difference of behavior between them.

If you have any other ideas for how to complete this - please feel free to say so. Thank you in advance for your help!

-Laura
 
but immediately after the user types the '1', the Selected Index event changes.
Yes, it does (SelectedIndexChanged event). Do you have something there that causes the problem?
 
I was hoping to have the user be able to type in a number - and not have the selected index change until they deliberately complete the selection of the drop down box (similar to many forms on the web - such as countries in an address form). The selectedIndexChanged event occurs immediately after a key is pressed. I would like to hold off on that event being kicked off until after they are done with choosing the option. Does this make sense? Thanks for your reply.
 
Oh...I think I might know what you mean. If I use the drop-down box closed event - the event won't be kicked off if I programatically set the selected index? If this is the case - then yeah, the dropdown closed event won't work.

Is there something that I could say similar to if dropdownbox.closed=true (kick off indexchanged events), else if dropdownbox.closed = false (don't do anything yet)?

The reason I want to do this is the following: When the user selects an option with the first combobox (month range), I populate the second combobox with the available months for that range, and set the index to the first option. I would like the user to be able to click 'Continue' without having to manually select an option in the second combobox if they want to use the default option.
 
could you explain what you mean about how the user can make a selection without using the dropdown box?
You can use keyboard navigation, tab into the the combo and use arrows to select/browse the options. Using the keyboard, the dropdown is not shown unless you Alt+down-arrow.
Is there something that I could say similar to if dropdownbox.closed=true (kick off indexchanged events), else if dropdownbox.closed = false (don't do anything yet)?
ComboBox.DroppedDown Property (System.Windows.Forms) So you can filter out the SelectedIndexChanged event when it is DroppedDown, and still allow all selection changes to be handled when dropdown is not used.
 
Back
Top