TabControl.SelectedTab.Name issue

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All,
I’m having a issue with the TabControl.SelectedTab.Name in the
SelectedIndexChanged method. All I want to do is keep track of what tab the
control is currently on. I have tried the following. I get an Index error or
Object is not an instance of a Object error. Is there a work around?
Thank you in advance.

Terry

gstrPrevTab = gstrCurrentTab
gstrCurrentTab = MyTabControl.SelectedTab.Name

And

Select Case MyTabControl.SelectedTab.Name
Case pgMyPage.Name
//do something here and move on
Case pgMyPage2.Name
//Same as above.
 
Terry said:
Hello All,
I'm having a issue with the TabControl.SelectedTab.Name in the
SelectedIndexChanged method. All I want to do is keep track of what tab
the
control is currently on. I have tried the following. I get an Index error
or
Object is not an instance of a Object error. Is there a work around?
Thank you in advance.

Terry

gstrPrevTab = gstrCurrentTab
gstrCurrentTab = MyTabControl.SelectedTab.Name

And

Select Case MyTabControl.SelectedTab.Name
Case pgMyPage.Name
//do something here and move on
Case pgMyPage2.Name
//Same as above.

Terry,

your first solution is exactly what u want (place those two lines in the
selectedindexchanged event) .. i m not sure why u r getting those errors ..
probably the problem lies somewhere else.

FUnky
 
FUnky,
I figured out what my issue was. When I was hiding/Clearing the tabpages I
was making a call like this: MyTabControl.TabPages.Clear(). Instead of using
the Clear() I started to use the MyTabControl.TabPages.Remove(MyTabPage).
Once I started using the Remove() the errors were no longer taking place. I
guest the Clear() isn't the same as the Remove().
Thank you for Responding to my post!

Terry
 
Back
Top