Docking Tab for WinForms | ComponentOne
Behavior / Closing Tab Pages
In This Topic
    Closing Tab Pages
    In This Topic

    DockingTab provides the functionality for the end-user to close the individual tabs in the control at runtime. For this purpose, C1DockingTab class provides the CanCloseTabs property.

    A close icon can be displayed in the tabs by setting the CanCloseTabs property to true, so that the end-user can close individual tab pages.

    Application UI displaying close icon

    The code snippet below shows how to close individual tab pages using CanCloseTabs.

    C#
    Copy Code
    dockingTab.CanCloseTabs = true;
    

    Close Icon in Caption Area

    A close icon can also be set in the caption area by setting both the CanCloseTabs and ShowCaption property to true.

    Application UI with the caption area showing closebox

    The code snippet below shows how to close individual tab pages using the close icon in the caption area:

    C#
    Copy Code
    dockingTab.CanCloseTabs = true;
    dockingTab.ShowCaption = true;
    

    CloseBox Position Enumeration

    A CloseBox can also be added to each tab using the CloseBoxPositionEnum. The following table lists the different options available in the CloseBoxPositionEnum to add a Close Box to active tab page, all tab pages etc.

    CloseBox options Snapshot
    CloseBox on the active page Appication UI with closebox on active page.
    CloseBox on all pages Appication UI with closebox on all pages.
    Default position of CloseBox Appication UI with default position of closebox.

    The code snippet below shows how to set CloseBox on an active page:

    C#
    Copy Code
    // Set the close box only on the active page
    dockingTab.CloseBox = CloseBoxPositionEnum.ActivePage;