Results 1 to 2 of 2

Thread: [2005] Combobox - This should have been easy

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    [2005] Combobox - This should have been easy

    I have a combobox (dropdown) control that depending on the selection enables the next control in the tab order. This control is also making use of the AutoComplete feature. I am watching the Validating and Validated events for this control. The Validating event is checking to see that a valid list item was entered and the Validated event is used to check the SelectedValue and enable/disable controls.

    The problem I am having is that by using the Validating/Validated events, the Tab has already occured and even if I enable the next control in Tab order, it gets skipped and focus is set the the next control in Tab order that was enabled prior to my code in the Validated event.

    For example, assume combo with a list of choices (Telephone, Fax, Cell) something like that. And then assume that there are 3 disabled textboxes, one for Telephone, one for Fax and one for Cell. Based upon the selection in the combo, the correct control is to be enabled. The way I have things working, selecting Fax and then hitting Tab would enable the Fax textbox, but would put focus on the Save button.

    I added a handler for the TextChanged event and that was great, but if the user uses the mouse to select the value and then hits the tab key, my newly enabled control gets passed over.

    There has to be a way around this, but I cannot see it.
    My.Settings.Signature = String.Empty

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Combobox - This should have been easy

    Are you saying that the user can select an item from the list or enter their own, but the other control will only be enabled if they select a list item? If so then don't wait for the Validating event. Handle the TextChanged and/or SelectedIndexChanged event. You can use the SelectedIndex property and/or the FindStringExact method to determine whether the user has selected a list item before they try to leave the control. A little experimentation will tell you what the best combination of event and member is.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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