Showing and Hiding Tab Items
- 2 minutes to read
#Hiding Tab Items
DXTabControl allows individual tab items to be hidden. A hidden tab item is not disposed and can be shown later. To hide a tab item in code, use the DXTabControl.HideTabItem method. An end-user can hide a tab item by clicking the close button displayed within a tab item's header.
The visibility of the close buttons is specified by the tab control view's TabControlViewBase.AllowHideTabItems property or individually for each tab item using the DXTabItem.AllowHide property.
Before a tab item is hidden, a DXTabControl.TabHiding event is fired, allowing you to cancel the action. To do this, set the event parameter's TabControlTabShowingEventArgs.Cancel property to true. The index of the tab item that is being hidden can be obtained by event parameter's TabControlTabShownEventArgs.TabIndex property. After the tab item has been hidden, a DXTabControl.TabHidden event is fired.
#Showing Tab Items
Hidden tab items can be shown in code using the DXTabControl.ShowTabItem method. An end-user can do this via the header menu, invoked when clicking an arrow displayed in the corner of the DXTabControl. The header menu's items correspond to tab items in the DXTabControl. Clicking a menu item automatically selects the corresponding tab item. The header menu can optionally include items that correspond to hidden tab items. This option is controlled by the TabControlViewBase.ShowHiddenTabItemsInHeaderMenu property. Clicking these menu items shows corresponding tab items within DXTabControl.
The visibility of the header menu is specified by the TabControlViewBase.ShowHeaderMenu property.
Before a tab item is shown, a DXTabControl.TabShowing event is fired, allowing you to cancel the action. To do this, set the event parameter's TabControlTabShowingEventArgs.Cancel property to true. The index of the tab item that is being shown can be obtained by event parameter's TabControlTabShownEventArgs.TabIndex property. After the tab item has been shown, the DXTabControl.TabShown event is fired.
#Removing Tab Items
Tab items can be removed in code via the DXTabControl.RemoveTabItem method. To enable end-users to remove tab items, set the view's TabControlViewBase.RemoveTabItemsOnHiding property to true. In this instance, tab items are removed after an end-user hides them.
Tab items cannot be removed when the tab control is data bound (the ItemsSource property is assigned). In this instance, calling the DXTabControl.RemoveTabItem method or hiding a tab item with the TabControlViewBase.RemoveTabItemsOnHiding property set to true throws an exception.