Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hello
 
how can I navigate to the previous TabPage in TabControl ( not the first one ) after I remove a tabpage
Posted 18-Jan-13 11:34am
Comments
Sergey Alexandrovich Kryukov at 18-Jan-13 17:48pm
   
What is TapControl? To tap in some window? or a door? Knock-knock... Nice idea, by the way. :-)
—SA
wisamsalwa at 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?
thanks
Sergey Alexandrovich Kryukov at 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)?
—SA
wisamsalwa at 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
system.windows.forms.tabcontrol 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 system.windows.forms.usercontrol - 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 at 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.
 
—SA
wisamsalwa at 20-Jan-13 4:41am
   
thank you
Sergey Alexandrovich Kryukov at 20-Jan-13 13:03pm
   
You are very welcome.
Good luck, call again.
—SA
Sergey Alexandrovich Kryukov at 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.
—SA

1 solution

Rate this: bad
good
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:
http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.selectedindex.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.selectedtab.aspx[^].
 
Or, it could be this one:
http://msdn.microsoft.com/en-us/library/system.windows.controls.tabcontrol.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.selector.selecteditem.aspx[^].
 
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?!
 
—SA
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 414
1 Maciej Los 180
2 Richard MacCutchan 140
3 DamithSL 129
4 Kornfeld Eliyahu Peter 119


Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid