Results 1 to 3 of 3

Thread: [2.0] Give a combobox focus on selecting a tabpage

  1. #1

    Thread Starter
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    [2.0] Give a combobox focus on selecting a tabpage

    Hi,

    I'm wondering if anyone can give me some suggestions on how to immediately give focus to a combobox on display of a tabpage. I tried setting it in the TabPage.Enter event, but it appears that the tabcontrol itself gets focus after the enter event. I'd like to avoid using timers and such, and am wondering if there is a good workaround to this or another event I can try handling. I've been through the list, and can't seem to find a good one to use.

    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

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

    Re: [2.0] Give a combobox focus on selecting a tabpage

    The solution looks something like this:
    Code:
    private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.tabControl1.SelectedTab == this.tabPage2)
        {
            this.comboBox1.Focus();
        }
    }
    but do ing that is generally not a good idea because it removes the ability to navigate the tabs using the keyboard. The reason that no child control receives focus when a tab is selected is that by the TabControl itself maintaining focus the user is able to move from tab to tab using the right and left arrow keys.
    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
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    Re: [2.0] Give a combobox focus on selecting a tabpage

    Ah. Makes sense enough. It's ok that the keyboard doesn't work, since it's for a touchscreen app anyway. I dunno why I wasn't looking at the TabControl itself... I got rusty

    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

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