Sheet Selector
The sheet selector is a pager displayed under the spreadsheet document that allows you to switch between the different worksheets.
The sheet selector is represented by the RadSpreadsheetSheetSelector
control, which is integrated in the ControlTemplate of the RadSpreadsheet
. This article describes how to access and customize the selector.
The RadSpreadsheetSheetSelector
control is located in the Telerik.Windows.Controls.Spreadsheet.Controls
namespace. To access it in XAML, use the following namespace: xmlns:spreadsheetControls="clr-namespace:Telerik.Windows.Controls.Spreadsheet.Controls;assembly=Telerik.Windows.Controls.Spreadsheet"
Hiding the Sheet Selector
By default the sheet selector component is displayed. To hide it, set the RadSpreadsheetSheetSelector.IsSheetSelectorVisible
attached property on the RadSpreadsheet
control to false
.
Setting the IsSheetSelectorVisible property
<telerik:RadSpreadsheet spreadsheetControls:RadSpreadsheetSheetSelector.IsSheetSelectorVisible="False"/>
Hiding the Add Sheet Button
By default the sheet selector has a button displayed next to the worksheeet tabs that allows to add new worksheets in the document. To hide the button, set the RadSpreadsheetSheetSelector.IsAddButtonVisible
attached property on the RadSpreadsheet
control to false
.
Setting the IsAddButtonVisible property
<telerik:RadSpreadsheet spreadsheetControls:RadSpreadsheetSheetSelector.IsAddButtonVisible="False"/>
Using the Tabs Context Menu
The worksheet tabs in the RadSpreadsheetSheetSelector
have a built-in context menu which allows you to apply few different settings on the tab - rename, insert, delete, hide, etc.
Sheet selector's context menu
The context menu can be modified or accessed via the SheetSelectorContextMenu
property of RadSpreadsheet
.
Customizing the existing context menu
private void RadSpreadsheet_Loaded(object sender, RoutedEventArgs e)
{
var spreadsheet = (RadSpreadsheet)sender;
// remove the last two options
spreadsheet.SheetSelectorContextMenu.Items.RemoveAt(spreadsheet.SheetSelectorContextMenu.Items.Count - 1);
spreadsheet.SheetSelectorContextMenu.Items.RemoveAt(spreadsheet.SheetSelectorContextMenu.Items.Count - 1);
// add a new option
var newMenuItem = new RadMenuItem();
newMenuItem.Header = "My option";
newMenuItem.Click += (s, args) =>
{
// implement the click logic here
};
spreadsheet.SheetSelectorContextMenu.Items.Add(newMenuItem);
}
Replacing the context menu
<telerik:RadSpreadsheet>
<telerik:RadSpreadsheet.SheetSelectorContextMenu>
<telerik:RadContextMenu>
<telerik:RadMenuItem Header="Option A" Click="OnOptionAClick"/>
<telerik:RadMenuItem Header="Option B" Click="OnOptionBClick"/>
</telerik:RadContextMenu>
</telerik:RadSpreadsheet.SheetSelectorContextMenu>
</telerik:RadSpreadsheet>
GetContextMenu
and SetContextMenu
methods of RadSpreadsheetSheetSelector
.
Using the GetContextMenu and SetContextMenu methods
private void RadSpreadsheet_Loaded(object sender, RoutedEventArgs e)
{
var spreadsheet = (RadSpreadsheet)sender;
var sheetSelector = spreadsheet.FindChildByType<RadSpreadsheetSheetSelector>();
// getting the menu
RadContextMenu contextMenu = sheetSelector.GetContextMenu();
// setting the menu
sheetSelector.SetContextMenu(newRadContextMenuInstance);
}