473,385 Members | 1,867 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,385 software developers and data experts.

Set focus on a tabpage

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 what I do. Any suggestions?
Public Sub SetTabs(ByVal TabID As String)

For Each Ctrl As Control In Me.Controls

If TypeOf Ctrl Is TabControl Then

If Ctrl.HasChildren Then

For Each cCtrl As Control In Ctrl.Controls

If TypeOf cCtrl Is TabPage Then

If cCtrl.Name = TabID Then

Ctrl.Enabled = True

Ctrl.Visible = True

cCtrl.Enabled = True

cCtrl.Visible = True

Me.ActiveControl = cCtrl

Else

cCtrl.Enabled = False

End If

End If

Next

Else

Ctrl.Enabled = True

Ctrl.Visible = True

Me.ActiveControl = Ctrl

End If

End If

Next

End Sub

Jun 19 '07 #1
2 14292
On Jun 19, 4:23 pm, "John Wright" <riley_wrig...@hotmail.comwrote:
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 what I do. Any suggestions?

Public Sub SetTabs(ByVal TabID As String)

For Each Ctrl As Control In Me.Controls

If TypeOf Ctrl Is TabControl Then

If Ctrl.HasChildren Then

For Each cCtrl As Control In Ctrl.Controls

If TypeOf cCtrl Is TabPage Then

If cCtrl.Name = TabID Then

Ctrl.Enabled = True

Ctrl.Visible = True

cCtrl.Enabled = True

cCtrl.Visible = True

Me.ActiveControl = cCtrl

Else

cCtrl.Enabled = False

End If

End If

Next

Else

Ctrl.Enabled = True

Ctrl.Visible = True

Me.ActiveControl = Ctrl

End If

End If

Next

End Sub
You need to grab the tabpage object (or it's index) and then set
either the tabcontrol's selectedtab or selectedindex property to show
the tabpage.

Thanks,

Seth Rowe

Jun 20 '07 #2
Bingo. Thanks. I had to modify the code a little. I had to create a
tabcontrol object and set it = to the ctrl. Once this was done, I could set
the selectedtab to the tabpage I had. Thanks.

John
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@w5g2000hsg.googlegro ups.com...
On Jun 19, 4:23 pm, "John Wright" <riley_wrig...@hotmail.comwrote:
>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 what I do. Any
suggestions?

Public Sub SetTabs(ByVal TabID As String)

For Each Ctrl As Control In Me.Controls

If TypeOf Ctrl Is TabControl Then

If Ctrl.HasChildren Then

For Each cCtrl As Control In Ctrl.Controls

If TypeOf cCtrl Is TabPage Then

If cCtrl.Name = TabID Then

Ctrl.Enabled = True

Ctrl.Visible = True

cCtrl.Enabled = True

cCtrl.Visible = True

Me.ActiveControl = cCtrl

Else

cCtrl.Enabled = False

End If

End If

Next

Else

Ctrl.Enabled = True

Ctrl.Visible = True

Me.ActiveControl = Ctrl

End If

End If

Next

End Sub

You need to grab the tabpage object (or it's index) and then set
either the tabcontrol's selectedtab or selectedindex property to show
the tabpage.

Thanks,

Seth Rowe

Jun 20 '07 #3

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...
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...
3
by: Paul Close | last post by:
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...
11
by: Dave | last post by:
Access 2003 I have a main form with two tab forms, one showing Client, and the other Spouse info, each with Address tabs. When I click on the Client address tab, I would like to have the...
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...
1
by: Localbar | last post by:
Hi all, For example I have a Tabcontrol and 5 tabpage. I would like to set focus to tabpage 3 after some validation in form. I try to do it..but cann't. Any idea hwo to do it. Thanks
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
11
by: =?Utf-8?B?RWl0YW4=?= | last post by:
Hello, I have a WinForm application. The form has one Tab Control and one ToolStrip. I would like to know what would be the best way to detect when the user is "leaving" the Tab Control and...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.