Tabcontrol1.SelectedTab close?

Untouchable

Member
Joined
Aug 6, 2006
Messages
11
Programming Experience
Beginner
Im trying to figure out how to close an active tab but cant really figure it out..

Also, i am wondering how I can assign a context menu to the Tab-buttons only, not the whole tabcontrol? Cheers!
 
Well there is no close method, but there is a hide method you can use to make it appear like it has been closed.

About the context menu, you can make a context menu appear anywhere so it's possible. You will have to use the bounds property of the tabpage and work out where the tab button is and set a listener to 'listen' for right mouse clicks inside that rectangle.
 
i tried that too, but i think im just totally stupid, because
VB.NET:
TabControl1.SelectedTab.Hide()
just results in the contents of the tabpage to be hidden, not the tabpage itself.. (including the tabpage button)..

Care to shed some light?

Cheers!
 
Strange, this was supposed to be fixed in .Net 2.0. Oh well you may just have to resort to the old method.

Create a Class level varaible of the type tabpage.

VB.NET:
Private TB as tabpage

Add this code to remove the tabpage from the tab control and
assign the class level variable to the tabpage you want to remove, so that you can always put it back later.


VB.NET:
TB = tabcontrol.TabPages(index of the tabpage you want to 'hide')
Tabcontrol.Tabpages.Remove(Your TabPage you want to 'hide')
 
Back
Top