[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
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.
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