TabControl.SelectedTab.Name issue

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.
 
F

FUnky

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top