There is no such concept as "close" for a tab page. You can delete one, here is how:
http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.tabpages.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.tabpagecollection.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.tabpagecollection.remove.aspx[
^] or:
http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.tabpagecollection.removeat.aspx[
^].
Note, that there is no such thing as "from within itself" or not. Typically, you invoke some events, and the event handler is an anonymous method or a method of, typically, a form or a window. For example:
myDeleteButton.Click += (sender, eventArgs) => {
myTabControl.TabPages.RemoveAt(myTabControl.SelectedIndex);
};
The references above are for
System.Windows.Forms
, but the code for WPF (and probably some other libraries) will be very similar.
Note: you should always tag the UI library or application type you are using when UI is involved.
—SA