473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Can't set focus to controls on TabPage

A new solution/project consisting of a single windows form with a tab
control, 3 tab pages and a text box on each tab page. I expected the
following to set focus to the text box on the selected tab page but it does
not.

Private Sub TabControl1_SelectedIndexChanged(...etc
Select Case TabControl1.SelectedIndex
Case 0
txtBox1.Focus()
Case 1
txtBox2.Focus()
Case 2
txtBox3.Focus()
End Select
End Sub

CanFocus is false for the tab page and the text box while in the sub.
TabControl1.SelectedTab = TabPage1 before txtBox1.Focus() doesn't help
either.

What am I missing?

Thanks
Nov 21 '05 #1
3 7023
is this code in your page load even by any chance? because it wont work
there
"Paul Close" <su*****@computerdoctor.com.au> wrote in message
news:O0**************@TK2MSFTNGP09.phx.gbl...
A new solution/project consisting of a single windows form with a tab
control, 3 tab pages and a text box on each tab page. I expected the
following to set focus to the text box on the selected tab page but it does
not.

Private Sub TabControl1_SelectedIndexChanged(...etc
Select Case TabControl1.SelectedIndex
Case 0
txtBox1.Focus()
Case 1
txtBox2.Focus()
Case 2
txtBox3.Focus()
End Select
End Sub

CanFocus is false for the tab page and the text box while in the sub.
TabControl1.SelectedTab = TabPage1 before txtBox1.Focus() doesn't help
either.

What am I missing?

Thanks

Nov 21 '05 #2
It's the tab control SelectedIndexChanged event handler. No other user
entered code in the project.

"Brian Henry" <br**********@newsgroups.nospam> wrote in message
news:uo*************@TK2MSFTNGP14.phx.gbl...
is this code in your page load even by any chance? because it wont work
there
"Paul Close" <su*****@computerdoctor.com.au> wrote in message
news:O0**************@TK2MSFTNGP09.phx.gbl...
A new solution/project consisting of a single windows form with a tab
control, 3 tab pages and a text box on each tab page. I expected the
following to set focus to the text box on the selected tab page but it
does not.

Private Sub TabControl1_SelectedIndexChanged(...etc
Select Case TabControl1.SelectedIndex
Case 0
txtBox1.Focus()
Case 1
txtBox2.Focus()
Case 2
txtBox3.Focus()
End Select
End Sub

CanFocus is false for the tab page and the text box while in the sub.
TabControl1.SelectedTab = TabPage1 before txtBox1.Focus() doesn't help
either.

What am I missing?

Thanks


Nov 21 '05 #3
You were on the right track Brian. Thanks. The tab control
SelectedIndexChanged event fires before the first form Load event so nothing
can recieve focus.

"Paul Close" <su*****@computerdoctor.com.au> wrote in message
news:Oi**************@TK2MSFTNGP10.phx.gbl...
It's the tab control SelectedIndexChanged event handler. No other user
entered code in the project.

"Brian Henry" <br**********@newsgroups.nospam> wrote in message
news:uo*************@TK2MSFTNGP14.phx.gbl...
is this code in your page load even by any chance? because it wont work
there

"Paul Close" <su*****@computerdoctor.com.au> wrote in message
news:O0**************@TK2MSFTNGP09.phx.gbl...
A new solution/project consisting of a single windows form with a tab
control, 3 tab pages and a text box on each tab page. I expected the
following to set focus to the text box on the selected tab page but it
does not.

Private Sub TabControl1_SelectedIndexChanged(...etc
Select Case TabControl1.SelectedIndex
Case 0
txtBox1.Focus()
Case 1
txtBox2.Focus()
Case 2
txtBox3.Focus()
End Select
End Sub

CanFocus is false for the tab page and the text box while in the sub.
TabControl1.SelectedTab = TabPage1 before txtBox1.Focus() doesn't help
either.

What am I missing?

Thanks



Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: M O J O | last post by:
Hi, Maybe this question has been asked before, but I've searched the net without finding any answer. I create a new solution, put a TabControl on Form1, create a TabPage and a put a TextBox...
5
by: Steve | last post by:
Visual Studio 2003 .Net / C# I have a 2 page Tab Control for users to add a Job in my application. The first page is for them to choose which type of Job they would like. The type of Job...
0
by: Chris Beach | last post by:
Hi there, I am using an Infragistics UltraWinTabControl control and require the focus to be switched to the first control on the selected tab page. I have used the following code, but the...
2
by: Paul Bromley | last post by:
I am using a tabcontrol alled for example:- TabPage There are several tabs on this tabcontrol with command buttons on them. I want to loop through them but the following code does not work:- ...
0
by: Redback | last post by:
Im using VS 2005. I have a form with a tab control. I have text boxes which are bound to a binding source, which is bound to a dataset. I have a button on the form that allows the user to add...
1
by: explode | last post by:
I have two tab pages.In the first tabpage I have some textboxes also in the second tabpage. I wont to get focus on Textbox3 (in tabpage2) when I enter the tabpage2 but it wont do that. This is my...
2
by: Rob | last post by:
Hi, I am adding Tab pages to a Tab control dynamically via the following statement... Form1.TabControl1.Controls.Add(ThePage) The next 2 statements also work... ThePage.Name = some string
2
by: John Wright | last post by:
I have the following routine I use to check for a certain tab page. I want to enable this tab page only on the tab control and set the focus. However, I cannot get the tab to set focus no matter...
5
by: Paul Hemans | last post by:
Hi, I am using VS2005. I have a form with a tabControl on it. Suddenly I can no longer see any of my controls, on any of the pages, or even the tabControl itself. They still exist because the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.