By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,027 Members | 1,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,027 IT Pros & Developers. It's quick & easy.

TabControl question

P: n/a
Hello
I have a TabControl1 in my Window Form. In this TabControl, I have three
tabs: TabPage1, TabPage2, TabPage3. I also have a button. What I want is
when I am in TabPage2 or TabPage2, I can click this button and I can see
TabPage1 ( I does not want to click on the tab). My code below (for the
button ) does not work
TabControl1.TabPages.Item(0).BringToFront()

Could you please tell me how to do that.

Many thanks

S.Hoa
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
shoa wrote:
Hello
I have a TabControl1 in my Window Form. In this TabControl, I have three
tabs: TabPage1, TabPage2, TabPage3. I also have a button. What I want is
when I am in TabPage2 or TabPage2, I can click this button and I can see
TabPage1 ( I does not want to click on the tab). My code below (for the
button ) does not work
TabControl1.TabPages.Item(0).BringToFront()

Could you please tell me how to do that.

Many thanks

S.Hoa


Hi,

I believe the TabControl has a property for this,
maybe it's called ActiveTab or SelectedTab.

Hope this helps.

stax
Nov 21 '05 #2

P: n/a
shoa wrote:
My code below (for the button ) does not work
TabControl1.TabPages.Item(0).BringToFront()


Try:

\\\
TabControl1.SelectedIndex = 0
///

You could also use the SelectedTab property if you want; this performs the
same function but takes a reference to a TabPage object instead of a tab
index.

Hope that helps,

--

(O)enone
Nov 21 '05 #3

P: n/a
"shoa" <so*@slingshot.co.nz> schrieb:
I have a TabControl1 in my Window Form. In this TabControl, I have three
tabs: TabPage1, TabPage2, TabPage3. I also have a button. What I want is
when I am in TabPage2 or TabPage2, I can click this button and I can see
TabPage1 ( I does not want to click on the tab). My code below (for the
button ) does not work
TabControl1.TabPages.Item(0).BringToFront()


\\\
Me.TabControl1.SelectedTab = Me.TabControl1.TabPages(1)
///

- or -

\\\
Me.TabControl1.SelectedIndex = 1
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #4

P: n/a
Personally, I always prefer referencing the tab by name.. I got caught out
when I reordered the order of tabs after my original development.. Whilst I
guess it's less efficient - you always get the tab you thought you wanted!

Regards
Simon
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:e$**************@TK2MSFTNGP14.phx.gbl...
"shoa" <so*@slingshot.co.nz> schrieb:
I have a TabControl1 in my Window Form. In this TabControl, I have three
tabs: TabPage1, TabPage2, TabPage3. I also have a button. What I want is
when I am in TabPage2 or TabPage2, I can click this button and I can see
TabPage1 ( I does not want to click on the tab). My code below (for the
button ) does not work
TabControl1.TabPages.Item(0).BringToFront()


\\\
Me.TabControl1.SelectedTab = Me.TabControl1.TabPages(1)
///

- or -

\\\
Me.TabControl1.SelectedIndex = 1
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5

P: n/a
"Simon Verona" <ne**@aphroditeuk.com> schrieb:
Personally, I always prefer referencing the tab by name.. I got caught out
when I reordered the order of tabs after my original development.. Whilst
I guess it's less efficient - you always get the tab you thought you
wanted!


ACK, it may be better to use the fields generated for the tabpages instead
of the 'TabPages' collection:

\\\
Me.TabControl1.SelectedTab = Me.TabPage1
///

When giving the tab pages meaningful names this will lead to more readable
code.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.