Results 1 to 4 of 4

Thread: [RESOLVED] TabControl - Focus Control - Form Load

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Resolved [RESOLVED] TabControl - Focus Control - Form Load

    Hi, All,

    I have a Tab Control within another Tab Control and I want to be able to focus the control within the child Tab Control on form load.
    I have attempted many different things and it is not working.
    I do have the tab click option working when you click the tab, the focus is given to the relevant control, but it is not working for me on form load.
    Any ideas?

    I want to focus the cursor in the Salutation ComboBox on form load.

    Screen shot attached.
    Attached Images Attached Images  

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

    Re: TabControl - Focus Control - Form Load

    You can't focus anything in the Load event handler because the form isn't actually visible at that stage. No matter what you do in the Load event handler, the first selectable control in the Tab order will be focused when the form is displayed. Unless you manipulate the Tab order, you need to handle the Shown event, which is raised immediately AFTER the form is displayed.
    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

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: TabControl - Focus Control - Form Load

    I didnt even realize there was a shown event. Learned something new. Issue resolved. Thanks for the pointer.

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

    Re: TabControl - Focus Control - Form Load

    Quote Originally Posted by BrailleSchool View Post
    I didnt even realize there was a shown event.
    There wasn't originally so you had to mess about with the Activated event and check whether it was the first time it had been raised. I think Shown was added in .NET 2.0.
    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