Version

Working with Tabs

Tabs

Each MdiTab object represents a single tab in the tabbed MDI interface and is associated with a particular MDI child form. MdiTab objects are automatically created and removed as MDI child forms are created and destroyed.

When an MDI child form is first created, an MdiTab object is created to represent that form and the InitializeTab event is fired. At that point, if the form is visible, the MdiTab must be associated with an MdiTabGroup object. The MdiTab objects for the forms that are not visible are stored in the HiddenMdiTabs collection. As the form is hidden or made visible, its associated MdiTab is moved between the HiddenTabs collection and an MdiTabGroup object. When a form is made visible, the TabDisplaying and TabDisplayed events will be invoked. (The TabDisplaying event will be invoked before the display has been updated.)

The tab portion of an MdiTab will display the caption text of the associated Form unless the Text property is explicitly set. By default, no image is displayed for an MDI tab. One can either be specified using the Image property of the TabAppearance object or by setting the DisplayFormIcon property to true. A tooltip will only be displayed for the tab if the ShowToolTips property of the UltraTabbedMdiManager class is true and either the ToolTip property is set to a string or there is not enough room to display the Text for the tab.

Tab Groups

An MdiTabGroup object is a container for one or more of visible MdiTab objects. Multiple tab groups may be created up to the maximum defined by the MaxTabGroups property of the element. The tab groups may either be oriented vertically or horizontally using the Orientation property.

Tab groups are created and destroyed as MdiTab objects are repositioned. When an MdiTabGroup is created, the InitializeTabGroup event will be invoked. Once all the MdiTab objects have been moved out of an MdiTabGroup, the tab group is removed and the size of the remaining tab groups are adjusted.

Note
Note

There must be at least one MdiTabGroup if there are any visible tabs/MDI child forms.

Tab Moving

Tabs may be moved into and out of a tab group programmatically or via the user interface. There are two ways to move a tab via the user interface - using the context menu that is displayed when you right click on a tab and by dragging a tab. The AllowDrop property of the MdiTabGroupSettings object can be used to limit which tabs may be dragged into a group. The AllowDrag property of the MdiTabSettings object may be used to determine where a particular tab may be repositioned. In addition, the element exposes events before a drag operation begins ( TabDragging event) and during the drag operation ( TabDragOver event) to determine if a particular point is a valid drop location. The TabDropped event is invoked when the drag operation is complete.

There are methods on the MdiTab, MdiTabGroup, and UltraTabbedMdiManager for programmatically repositioning a tab. The Reposition method of the MdiTab can be used to reposition a tab relative to another tab. The MoveToGroup method is used to move a tab to a different MdiTabGroup. The MoveToNewGroup method is used to create a new MdiTabGroup to contain the tab being moved (the new group is created and the tab is moved into it.)

When a tab is about to be moved from one MdiTabGroup to another, the TabMoving event will be invoked. The event may be cancelled to prevent the move operation from occurring. If the move operation is successful, the TabMoved event will be invoked.

Tab Selection

Selection is closely tied to the activation of the associated MDI child form since the tab that represents the active MDI child must be the selected tab in the tab group that contains it. For the other tab groups, the selected tab is based on the z-order of the MDI child forms.

When a tab is about to be selected, the TabSelecting event will be invoked. If the event is cancelled, the tab will not be selected and will not be activated. Otherwise, the tab is selected and its associated form is activated. The TabSelected event is then invoked.

Note
Note

In most situations the TabSelecting event may be cancelled but there are cases where the activation is externally controlled and cannot be prevented - such as when a new MDI child form is created.

TabGroup Size/Resizing

The size of an MdiTabGroup is based on its Extent . The ClientExtent is the extent of the tab group excluding the SplitterWidth . All tab groups except the last one will contain a splitter bar that may be used to resize the tab group. The tab group can also be adjusted programmatically by setting the Extent or ClientExtent. In addition, the extent of the tab groups must be updated as the size of the mdi client area changes.

When the splitter bar is about to be used to resize a tab group, the SplitterDragging event will be invoked. Cancelling this event will prevent the drag operation from beginning. If the event is not cancelled, the user will be allowed to reposition the splitter bar within the bounds of the tab group containing the splitter bar and the adjacent tab group after it. Once the splitter bar is released, the extents of the tab groups will be updated and the SplitterDragged event will then be invoked.

When the extent of one or more tab groups changes, the TabGroupResizing event will be invoked. The tab groups whose extents are being modified along with the new extents are specified in the event. The extents of the tab groups may be altered in this event before the display is changed. If the sum of the extents do not match the extent of the mdi client area, the extents will be adjusted to occupy the available area. Once the groups have been resized, the TabGroupResized event will be invoked.

Note
Note

The sum of the Extent values for all the tab groups must be equivalent to the extent of the mdi client area. If the tab groups are oriented vertically, then that value is the width of MdiClient’s client area. If they are oriented horizontally, then that value is the height of the MdiClient’s client area.

Tab Scrolling

Depending on the settings of the TabSizing and ScrollButtons properties, when there are more tabs than can be displayed within a tab group’s available area, scroll buttons are displayed. The scroll buttons that are displayed can be controlled using the ScrollButtonTypes property. When the scroll buttons are pressed, the TabGroupScrolling and TabGroupScrolled events will be invoked.

Tabs may be scrolled programmatically using the Scroll method of the MdiTabGroup. Also, the EnsureTabInView method of the MdiTab object may be used to ensure that a tab is in visible area of the tab group.