I have a problem with vb.net tabcontrol in so far as I cannot change the individual tab widths. I can chang ethe sizecontrol to fixed and alter all of the tabs but not individually. Ordinarily it would not be a problem with the tabs autosizing by the text size, but I have sometimes in my programme tabs with no content which I would like to hide, this I thought would be easy as just give it no name, but the tab remains and the size seems to have a minimum which is too big.

So to summerize. I want to hide dynamically one or more tabs in tabcontrol.

Recommended Answers

All 9 Replies

Hi
Sounds good, looks simple, but doesn't work.

I dont know what is happening with my programme. But it has now decided to work. I have made no changes since it was not working, but I was working in Access in another window, which is now closed. However even when I open access my programme still works. Very odd.
And if you want realy odd, I am now stuck on the wierdest fault I have ever encountered.
Here goes:
When opening an access DB using the following ver simple code:

ds.Tables("tblList").Rows(0).Item(1)

I inserts row 7

However if I use this code:

ds.Tables("tblList").Rows(0).Item("Tab1")

tab1 being the label for field1, it works fine.

to try to find this anomoly, I tried making a new table, same thing hapens. A new database, same thing happens. A copy of an old table - works until I add another field then it stops working again.

I am now just about ready to go smash my head in.

By the way thanks for the earlier solution.

Hi,

Stops working..? What error you are getting...?
post your code here..

Regards
Veena

I have finally fixed it, and the fix was far to compecated to explain and I doubt would be much use to anyone as it was a human error as usual. As the original posting was fixed I will now close off this discussion.
Thanks to Qveen72 for the solution to removing the tab. One last interesting thing is that when I posted that his solution wasn't working, this was true and it was becasue of a completely obscure problem with a sql statement when accessing an access database, its worth remembering that something completely seperate can cause things to not work which are seemingly unrelated.

Whilst I thought it was working I have now come accross another problem. Your code works great upto the 5th tab, then I get an error:
InvalidArgument=Value of '6' is not valid for 'index'. Parameter name: index
Its almost like it thinks tabcontrol tabpages is a real array that has not been declared.
Any ideas.

Hi,

How many tabs do you have...?
hope, you are aware that.. for tabcount = 6.. pages would be from 0 to 5..

Regards
Veena

Hi
Yes I have 12 tabs, yes so tab 6 is the 7th one.
I have now figured out how to do this, and it seems that you can't use an index to remove tabs, you can use it for pretty much everything else but not remove.
So here is how I got it to work:

Tabcontrol1.TabPages.Remove(Tagname1)
Tabcontrol1.TabPages.Remove(Tagname2)
'etc
Tabcontrol1.TabPages.Remove(Tagname7)

Hi,

I guess.. the problem, using Index is.. Once a Tab is removed, tabCount decreases.. and the all the tabs are Renumbered... Yes, you cant use index..

Regards
Veena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.