Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does TabPage.Hide() do?

I want to hide TabPage from TabControl.

I tried this way:

MyTabControls.TabPages[1].Hide();

It does not hide.

So I searched and saw that should delete it and recreate when you want to: How to hide TabPage from TabControl

In this case, what is the Hide function doing at all?

Screenshot:

enter image description here

like image 456
Hodaya Shalom Avatar asked Mar 20 '13 08:03

Hodaya Shalom


3 Answers

Sadly, you cannot do as you wish. You have to add and remove tabs and re-add them if you want that effect.

Try using this kind of syntax:

theTabControl.TabPages.Remove(tabPageA);

Then to re-add:

theTabControl.TabPages.Add(tabPageA);

Hide() - Hiding the control is equivalent to setting the Visible property to false. After the Hide method is called, the Visible property returns a value of false until the Show method is called.

Why you might use it - You might use Show() or Hide() when you know the value and use Visible when you take the visibility in as a parameter, although I would personally tend to always use Visible.

What it will do in this case - In this case it is useless and will not do anything. Just like Visible(), the following applies to it:

"TabPage controls are constrained by their container, so some of the properties inherited from the Control base class will have no effect, including Top, Height, Left, Width, Show, and Hide."

like image 114
dsgriffin Avatar answered Oct 06 '22 23:10

dsgriffin


The reason is stated on MSDN as

TabPage controls are constrained by their container, so some of the properties inherited from the Control base class will have no effect, including Top, Height, Left, Width, Show, and Hide.

The tabs in a TabControl are part of the TabControl but not parts of the individual TabPage controls. Members of the TabPage class, such as the ForeColor property, affect only the client rectangle of the tab page, but not the tabs. Additionally, the Hide method of the TabPage will not hide the tab. To hide the tab, you must remove the TabPage control from the TabControl.TabPages collection.

like image 38
V4Vendetta Avatar answered Oct 06 '22 23:10

V4Vendetta


As the TabPage class is derived from the Control class it has to have at least the methods Control has. So the Hide() function cannot be removed although it has no effect. It's not there because it does something but because of the relation to the Control class.

(Don't ask me why it has no effect. I would like to just Hide() my tabs as well.)

like image 22
Konrad Avatar answered Oct 06 '22 22:10

Konrad