Click here to Skip to main content
13,350,289 members (45,211 online)
Rate this:
Please Sign up or sign in to vote.
See more:

how can I navigate to the previous TabPage in TabControl ( not the first one ) after I remove a tabpage
Posted 18-Jan-13 12:34pm
Sergey Alexandrovich Kryukov 18-Jan-13 17:48pm
What is TapControl? To tap in some window? or a door? Knock-knock... Nice idea, by the way. :-)
wisamsalwa 19-Jan-13 10:40am
hi Sergey
I mean System.Windows.Forms.tabControl

and my question is about showing the previous tabpage(e.g: with index = 2 , if we were in 3'd tabpage before removing it) , I also remove each bage using a closebutton component which is a member of a usercontrol that added to a tabpage at creation ,

any shortcuts?
Sergey Alexandrovich Kryukov 19-Jan-13 17:51pm
I got it; it was just a little fun.
I gave you a complete answer to your question. These two properties I referenced is all you need. Did you get it?
Are you going to accept it formally (green button)?
wisamsalwa 19-Jan-13 19:27pm
I know that I'm talking with a clever man (Andalso I see your name in the top experts list) , but unfortunately my English is the main problem here , and I think that if you catch the point it well be a nice thing to think about. honestly, if I missed MSDN as a reference thats mean that I'm in big trouble..

sergey ,
the point is (with Mathematical ENGLISH ) :
myForm --> in its members called TC1
TC1 ==> have just one tabpage lets call it tp(0) , this is the only one user cannot remove , tp(0) contains a datagridview _ doubleclick on a row on it fire adding tabpages in TC1 , lets call it tp(i) : where i>0

each tp(i) contains a panel wich is a - call it - UC

in a UC , I create an "X" button (Component Inherits Button) to remove tp(i)
if User click this (each) button
my question is:

the i'th "X" button remove tp(i)
but after tp(i) is removed the selected tabpage is tp(0) , what i need is to set::

TC1.SelectedTab = tp(i-1)

thanks a million
Sergey Alexandrovich Kryukov 19-Jan-13 20:11pm
Apparently, you will need to select the tab of your choice. You need to be careful of numbering, as when you remove one page, the numbering will be shifted (of course, not if you want the previous page (before the deleted one), and such page existed). Also, you need to take care of the situation when no pages left.

It might be simpler of you chose the page to select before removal. It will be easier if you use SelectedTab, not SelectedIndex. SelectedTab require reference to the page you choose to select after deletion; and the reference cannot be "shifted" :-)

That's all what is involved. Everything else is per your design.

wisamsalwa 20-Jan-13 4:41am
thank you
Sergey Alexandrovich Kryukov 20-Jan-13 13:03pm
You are very welcome.
Good luck, call again.
Sergey Alexandrovich Kryukov 18-Jan-13 17:49pm
Now, one little problem is: you did not tell us the type of TabControl. Do you think there is only one under this name? No. So, in all cases, please, a full name.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Right. Of course you should take care about it. But, as I say, it really depends on what class are you talking about.

It could be:[^],[^].

Or, it could be this one:[^],[^].

Or, it could be some other library.

You should really always tag the library or application type you are using. Better yet, you should read documentation by yourself. Looking at your question, I'm afraid to imagine what else will you need to ask working is this ineffective style. Did you ever ask yourself how many properties and types are there in FCL?!


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.180111.1 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100