Results 1 to 6 of 6

Thread: control.TabStop gives combobox a focus

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2021
    Posts
    8

    Question control.TabStop gives combobox a focus

    When I set

    comboA.TabStop = False

    The comboA will get focused.

    I found a thread about this:
    https://www.vbforums.com/showthread....hlight=tabstop

    So, is this a bug?

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,195

    Re: control.TabStop gives combobox a focus

    Are you saying that when you press the Tab key focus moves to comboA? Need a full explanation.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2021
    Posts
    8

    Re: control.TabStop gives combobox a focus

    Quote Originally Posted by wes4dbt View Post
    Are you saying that when you press the Tab key focus moves to comboA? Need a full explanation.
    No, when the form displayed first time, without any extra action.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: control.TabStop gives combobox a focus

    When a form is displayed, if it contains controls that can receive focus then one of those controls will receive focus. By default, that will be the first control in the Tab order. If you want a different control to receive focus by default then you need to make it the first control in the Tab order. If you want a control other than the first in the Tab order to have focus when a form is displayed then you need to do that manually. Handle the Shown event of the form, which is raised immediately after the form is displayed for the first time, and call the Select method of the control you want to have focus.

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: control.TabStop gives combobox a focus

    Quote Originally Posted by jmcilhinney View Post
    When a form is displayed, if it contains controls that can receive focus then one of those controls will receive focus. By default, that will be the first control in the Tab order. If you want a different control to receive focus by default then you need to make it the first control in the Tab order. If you want a control other than the first in the Tab order to have focus when a form is displayed then you need to do that manually. Handle the Shown event of the form, which is raised immediately after the form is displayed for the first time, and call the Select method of the control you want to have focus.
    @ChrisAka - If you Select a Label, you won't see any focus on Form_Shown

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: control.TabStop gives combobox a focus

    Quote Originally Posted by .paul. View Post
    If you Select a Label, you won't see any focus on Form_Shown
    Or you could just set ActiveControl to Nothing if you don't want there to be an active control.

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