Click here to Skip to main content
15,877,051 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I have a Windows form with a Tab Control displaying 6 tabs.
I need to hide/remove the tabs depending on certain condition.
Which is the better way to achieve this? using Remove() or Dispose()?
Posted

 
Share this answer
 
Call Remove() to remove tabs from the tab control.
Calling Dispose() will not remove the tab.

In general, Dispose() should always be called after Remove() to allow memory resources to be cleared up.
 
Share this answer
 
v2
try this
MIDL
// Removes the selected tab:
tabControl1.TabPages.Remove(tabControl1.SelectedTab);
// Removes all the tabs:
tabControl1.TabPages.Clear();

Exact use of Dispose methord
Use this method to close or release unmanaged resources such as files, streams, and handles held by an instance of the class

When, How, Where and Why to use Dispose[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900