Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > How to set the TAB Control visible
 

How to set the TAB Control visible

I have a tab control with 2 index, now in some case i want one of the visible mode of index should false...

Can anybody help me in doing this..

Thanks

Srinig29  Tuesday, February 19, 2008 1:04 PM
Hi

This is not possible by default in Windows forms. You have to write some code and extend the TabControl. I posted an "extended TabControl" on my blog.

Basically you remove and you add a tabpage to the tabcontrol when you need to.
Like this:

if (show)
{
myTabControl.Insert(tabProductCompound);
}
else
{
myTabControl.Remove(tabProductCompound);
}
DamPee  Tuesday, February 19, 2008 2:51 PM

if (show)
{
microsoftTabControl.Pages.Insert(new TabPage("new page"));
}
else
{
microsoftTabControl.Pages.Remove(pageToRemove);

}

SunilCS  Thursday, February 28, 2008 9:45 AM
Hi

This is not possible by default in Windows forms. You have to write some code and extend the TabControl. I posted an "extended TabControl" on my blog.

Basically you remove and you add a tabpage to the tabcontrol when you need to.
Like this:

if (show)
{
myTabControl.Insert(tabProductCompound);
}
else
{
myTabControl.Remove(tabProductCompound);
}
DamPee  Tuesday, February 19, 2008 2:51 PM
There is no way to make a tab invisible. You have to remove the tab from the tabcontrols tab collection
Ken Tucker  Tuesday, February 19, 2008 2:54 PM

There is no Remove() method.. Wat should i do now?
Srinig29  Wednesday, February 20, 2008 11:58 AM

Are you working on Windows Forms? There *must* be a remove method on the TabPages collection.

As mentioned on: MSDN TabControl Class page:

"To hide the tab, you must remove the TabPage control from the TabControl..::.TabPages collection."

See my first post for a complete solution.

DamPee  Wednesday, February 20, 2008 12:04 PM
Yes I'm in windows form

Srinig29  Wednesday, February 20, 2008 1:07 PM

Then it works. Follow all the links which have been provided and read the documentation.

If it doesn't work post some relevant code and describe what goes wrong.

DamPee  Wednesday, February 20, 2008 1:09 PM

Thanks Damiaan, As u said i haveremoved the tabpage and added if ness....

Srinig29  Wednesday, February 27, 2008 7:42 AM

Hi,

Additionaly, You could do like this :

if (show)
{
microsoftTabControl.TabPages.Insert(new TabPage("New Page"));

}
else
{
microsoftTabControl.TabPages.Remove(yourPageName);

}

SunilCS  Thursday, February 28, 2008 9:43 AM

if (show)
{
microsoftTabControl.Pages.Insert(new TabPage("new page"));
}
else
{
microsoftTabControl.Pages.Remove(pageToRemove);

}

SunilCS  Thursday, February 28, 2008 9:45 AM

You can use google to search for other answers

Custom Search

More Threads

• Handling Null data items from an Access database
• dataadapter.update Concurrency violation
• datagridviewcomboboxcell
• VB.NET-BindingSource/DataGridView
• Refreshing Datagrid
• How to read xml into a listbox
• Listview : Sort problem.
• How to loop through an unselected CheckedListBox ?
• Using XML file as a data storage via Typed Dataset
• Where is the code?