Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 517973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:53:22+00:00 2026-05-13T07:53:22+00:00

I’ve reached a bit of an impasse when developing a .NET windows forms app.

  • 0

I’ve reached a bit of an impasse when developing a .NET windows forms app. The problem has to do with switching focus between controls, and how it plays with maintaining the form’s control’s states.

There are three main controls in the UI – two combo boxes and a button.

  • Both combo boxes start off with SelectedItem = null.
  • Both combo boxes have an explicit set of valid options that can be selected.
  • Both combo boxes are using AutoCompleteMode.SuggestAppend, with the AutoCompleteSource set to AutoCompleteSource.ListItems. This means users can type in to the combo boxes and have suggestions pop up for the value to select.
  • ComboBox #1 is always enabled.
  • ComboBox #2 is disabled unless a specific value has been selected in ComboBox #1.
  • The button is enabled only when:
    • A valid value has been selected from the always-enabled combo box.
    • A valid value has been selected from the second combo box IFF a specific value has been selected in the first combo box. Otherwise, its value is ignored.
    • In all other cases it is disabled.

The problem is to do with keyboard navigation and control focus, and how they play together with the logic associated with maintaining the Enabled states of the various controls.

In a nutshell, when selecting a value for a combo box, pressing TAB (to make your selection for the combo box) gives focus to the next control on the form (as per the TabIndex order) BEFORE the logic to enable/disable controls is run.

The logic to enable/disable the controls is happening in the Validating/Validated events of the associated combo boxes.

The net result is that a control can be disabled AFTER it has been given focus.

For example:

  1. Only ComboBox #1 is enabled. ComboBox #2 and the Button are disabled. All ComboBox’s SelectedItem are set to null.
  2. Set focus to ComboBox #1.
  3. Type the first few letters of a valid option for the box.
  4. Press TAB.

When I press TAB, it seems that focus is given to the next control before the SelectedItem is changed. The business logic to enable or disable the other UI controls can’t be run until SelectedItem is changed.

Ideally, what I want is the other way around: focus should be shifted AFTER the UI control’s SelectedItem has been updated, thus the logic to update the control’s states has been run.

Does anybody have any suggestions as to how I could go about doing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:53:22+00:00Added an answer on May 13, 2026 at 7:53 am

    Can you explicitly change focus in SelectedIndexChanged / SelectedValueChanged for the appropriate combo box? You might want to check where focus is currently, and only shift if it’s on the disabled control.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 297k
  • Answers 297k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I found the solution of this problem today. This is… May 13, 2026 at 7:17 pm
  • Editorial Team
    Editorial Team added an answer One solution is to place the connection string to the… May 13, 2026 at 7:17 pm
  • Editorial Team
    Editorial Team added an answer The sort method accepts a function in which you can… May 13, 2026 at 7:17 pm

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.