# Restricting the Usage of Specific Tabs

Get started with Menus and Toolbars for WinForms. Create versatile menus and docking/floating toolbars. See more in documentation here.

## Content



You can add a handler to the [SelectedIndexChanging](/componentone/docs/win/online-menus-toolbar/) event to test whether the index of the page is the page that you don't want the user to switch to. If so, e.Cancel would be set to **True**. For example, the following code shows how to add a handler to the [SelectedIndexChanging](/componentone/docs/win/online-menus-toolbar/) event:

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in Visual Basic

DOC-SUMMARY-TAG-CLOSE

```vbnet
Private Sub c1DockingTab1_SelectedIndexChanging(sender As Object, e As C1.Win.C1Command.SelectedIndexChangingEventArgs)
   If e.NewIndex = 1 And e.CanCancel Then
      e.Cancel = True
   End If
End Sub
```

DOC-DETAILS-TAG-CLOSE

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in C#

DOC-SUMMARY-TAG-CLOSE

```csharp
private void c1DockingTab1_SelectedIndexChanging(object sender, C1.Win.C1Command.SelectedIndexChangingEventArgs e)
{
   if(e.NewIndex == 1 && e.CanCancel)
      e.Cancel = true;
}
```

DOC-DETAILS-TAG-CLOSE

## See Also

[NavBar Tasks](/componentone/docs/win/online-menus-toolbar/menusandtoolbarsforw2/navbartasks)