# Tab Closing

## Content



By default, users can't close the tabs on a C1TabControl control. You can add a close button to each tab by setting the [TabItemClose](/componentone/api/wpf/online-tabcontrol5/dotnet-api/C1.WPF.TabControl/C1.WPF.TabControl.C1TabControl.TabItemClose.html) property to **InEachTab**. This will allow users to close any tab in the control. On-tab close buttons appear as follows:

![](https://cdn.mescius.io/document-site-files/images/fd13627f-3e59-47ec-89e2-86c13c4f9d2c/images/tabcontrol/tabitemclose.png)

If you prefer, you can create a global close button that will appear on the tabstrip instead of directly on the tabs. To add the global close button, you set the **TabItemClose** property to **GlobalClose**. Clicking the global close button will close the currently selected tab. The global close button appears as follows:

![](https://cdn.mescius.io/document-site-files/images/fd13627f-3e59-47ec-89e2-86c13c4f9d2c/images/tabcontrol/globalclosebutton.png)

To allow users to close tabs, follow one of the following methods:

### In XAML

To allow users to close tabs using a universal button, add **TabItemClose="GlobalClose"** to **<c1:C1TabControl>** tab so that the markup resembles the following:

```xml
<c1:C1TabControl TabItemClose="GlobalClose"></c1:C1TabControl>
```

### In Code

Complete the following steps:

1.  Switch to Code view.
2.  Add the following code beneath the **InitializeComponent()** method:

```vbnet
C1TabControl1.TabItemClose = GlobalClose
```

```csharp
c1TabControl1.TabItemClose = GlobalClose;
```

3.  Run the program.

### At Design Time

Complete the following steps:

1.  Select the **C1TabControl** control.
2.  In the Properties window, click the **TabItemClose** drop-down arrow and select **GlobalClose** from the list.

To prevent a user from closing a particular tab, use one of the following methods:

### In XAML

To prevent a user from closing a tab, add **CanUserClose="False"** to the **<c1:C1TabItem>** tag of the tab you want to prevent users from closing. The XAML will resemble the following:

```xml
<c1:C1TabItem CanUserClose="False"></c1:C1TabControl>
```

### In Code

Complete the following steps:

1.  Switch to Code view.
2.  Add the following code beneath the **InitializeComponent()** method:

```vbnet
C1TabItem1.CanUserClose = False
```

```csharp
c1TabItem1.CanUserClose = false;
```

3.  Run the program.

### At Design Time

Complete the following steps:

1.  Select the tab that you wish to prevent users from closing.
2.  In the Properties window, clear the **CanUserClose** check box.