Class RadSpreadsheetElement
Represents the core element of the RadSpreadsheet control that provides comprehensive spreadsheet functionality including worksheet editing, formula bar, status bar, and sheet navigation.
Inheritance
Inherited Members
Namespace: Telerik.WinControls.UI
Assembly: Telerik.WinControls.RadSpreadsheet.dll
Syntax
public class RadSpreadsheetElement : LightVisualElement, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IComponent, IDisposable, IBindableComponent, ISupportDrag, ISupportDrop, IShortcutProvider, IStylableElement, IStylableNode, IPrimitiveElement, IShapedElement, IFillElement, IBorderElement, IBoxStyle, IBoxElement, IDrawFillElement, IImageElement, ITextPrimitive, ITextProvider, ICommandDescriptorsProvider, IScrollBarsProvider, IWeakEventListener
Constructors
RadSpreadsheetElement()
Initializes a new instance of the RadSpreadsheetElement class with default settings and components. Sets up the input handler, sheet selector, status bar, themes, and worksheet editor components.
Declaration
public RadSpreadsheetElement()
Fields
ActiveSheetEditorProperty
Identifies the ActiveSheetEditor dependency property.
Declaration
public static readonly RadProperty ActiveSheetEditorProperty
Field Value
|
RadProperty
|
CommandDescriptorsProperty
Identifies the CommandDescriptors dependency property.
Declaration
public static readonly RadProperty CommandDescriptorsProperty
Field Value
|
RadProperty
|
FillHandleSelectionStrokeProperty
Identifies the FillHandleSelectionStroke dependency property.
Declaration
public static readonly RadProperty FillHandleSelectionStrokeProperty
Field Value
|
RadProperty
|
FormulaBarHeightProperty
Identifies the FormulaBarHeight dependency property.
Declaration
public static readonly RadProperty FormulaBarHeightProperty
Field Value
|
RadProperty
|
SelectionFillProperty
Identifies the SelectionFill dependency property.
Declaration
public static readonly RadProperty SelectionFillProperty
Field Value
|
RadProperty
|
SelectionStrokeProperty
Identifies the SelectionStroke dependency property.
Declaration
public static readonly RadProperty SelectionStrokeProperty
Field Value
|
RadProperty
|
SelectionStrokeThicknessProperty
Identifies the SelectionStrokeThickness dependency property.
Declaration
public static readonly RadProperty SelectionStrokeThicknessProperty
Field Value
|
RadProperty
|
StatusBarHeightProperty
Identifies the StatusBarHeight dependency property.
Declaration
public static readonly RadProperty StatusBarHeightProperty
Field Value
|
RadProperty
|
WorkbookProperty
Identifies the Workbook dependency property.
Declaration
public static readonly RadProperty WorkbookProperty
Field Value
|
RadProperty
|
WorksheetEditorContextMenuProperty
Identifies the WorksheetEditorContextMenu dependency property.
Declaration
public static readonly RadProperty WorksheetEditorContextMenuProperty
Field Value
|
RadProperty
|
Properties
ActiveSheet
Gets or sets the currently active sheet within the workbook.
Declaration
public Sheet ActiveSheet { get; set; }
Property Value
|
Sheet
|
ActiveSheetEditor
Gets the currently active sheet editor that provides editing functionality for the current sheet.
Declaration
public IRadSheetEditor ActiveSheetEditor { get; }
Property Value
|
IRadSheetEditor
|
ActiveWorksheet
Gets or sets the currently active worksheet, providing typed access to worksheet-specific functionality.
Declaration
public Worksheet ActiveWorksheet { get; set; }
Property Value
|
Worksheet
|
ActiveWorksheetEditor
Gets or sets the active worksheet editor that provides editing capabilities for the current worksheet.
Declaration
public RadWorksheetEditor ActiveWorksheetEditor { get; set; }
Property Value
|
RadWorksheetEditor
|
ColorPalette
Gets or sets the color palette used for cell formatting and theming operations.
Declaration
public SpreadsheetColorPalette ColorPalette { get; set; }
Property Value
|
SpreadsheetColorPalette
|
CommandDescriptors
Gets the collection of command descriptors available for spreadsheet operations.
Declaration
public CommandDescriptors CommandDescriptors { get; }
Property Value
|
CommandDescriptors
|
Implements
CreateVisualCellsAutomationPeers
This property is not relevant for this class.
Declaration
public bool CreateVisualCellsAutomationPeers { get; set; }
Property Value
|
System.Boolean
|
FillHandleSelectionStroke
Gets or sets the brush used to draw the fill handle selection indicator.
Declaration
public Brush FillHandleSelectionStroke { get; set; }
Property Value
|
System.Drawing.Brush
|
FontsProvider
Gets the fonts provider that manages font information and font families for the spreadsheet.
Declaration
public FontsProvider FontsProvider { get; }
Property Value
|
FontsProvider
|
FormulaBar
Gets the formula bar element that allows editing of cell formulas and values.
Declaration
public RadSpreadsheetFormulaBar FormulaBar { get; }
Property Value
|
RadSpreadsheetFormulaBar
|
FormulaBarHeight
Gets or sets the height of the formula bar in pixels.
Declaration
public int FormulaBarHeight { get; set; }
Property Value
|
System.Int32
|
HorizontalScrollBar
Gets the horizontal scroll bar element for navigating the worksheet horizontally.
Declaration
public RadScrollBarElement HorizontalScrollBar { get; }
Property Value
|
RadScrollBarElement
|
Implements
InputHandler
Gets or sets the input behavior handler that manages keyboard and mouse interactions for the spreadsheet.
Declaration
public SpreadsheetInputBehavior InputHandler { get; set; }
Property Value
|
SpreadsheetInputBehavior
|
PrintManager
Gets the print manager that provides printing functionality for the spreadsheet content.
Declaration
public PrintManager PrintManager { get; }
Property Value
|
PrintManager
|
SelectionFill
Gets or sets the brush used to fill the background of selected cells and ranges.
Declaration
public Brush SelectionFill { get; set; }
Property Value
|
System.Drawing.Brush
|
SelectionStroke
Gets or sets the brush used to draw the outline of selected cells and ranges.
Declaration
public Brush SelectionStroke { get; set; }
Property Value
|
System.Drawing.Brush
|
SelectionStrokeThickness
Gets or sets the thickness of the stroke used to outline selected cells and ranges.
Declaration
public double SelectionStrokeThickness { get; set; }
Property Value
|
System.Double
|
SheetSelector
Gets the sheet selector element that displays worksheet tabs and allows sheet navigation.
Declaration
public RadSpreadsheetSheetSelector SheetSelector { get; }
Property Value
|
RadSpreadsheetSheetSelector
|
SheetSelectorContextMenu
Gets or sets the context menu displayed when right-clicking on worksheet tabs in the sheet selector.
Declaration
public RadContextMenu SheetSelectorContextMenu { get; set; }
Property Value
|
RadContextMenu
|
ShouldChangeIconsOnThemeChange
This property is not relevant for this class.
Declaration
public virtual bool ShouldChangeIconsOnThemeChange { get; set; }
Property Value
|
System.Boolean
|
StatusBar
Gets the status bar element that displays information about the current selection and spreadsheet state.
Declaration
public RadSpreadsheetStatusBar StatusBar { get; }
Property Value
|
RadSpreadsheetStatusBar
|
StatusBarHeight
Gets or sets the height of the status bar in pixels.
Declaration
public int StatusBarHeight { get; set; }
Property Value
|
System.Int32
|
Theme
Gets or sets the document theme that defines colors, fonts, and effects for the spreadsheet.
Declaration
public DocumentTheme Theme { get; set; }
Property Value
|
DocumentTheme
|
ThemesManager
Gets the themes manager that handles document theme operations and theme switching.
Declaration
public RadSpreadsheetThemesManager ThemesManager { get; }
Property Value
|
RadSpreadsheetThemesManager
|
VerticalScrollBar
Gets the vertical scroll bar element for navigating the worksheet vertically.
Declaration
public RadScrollBarElement VerticalScrollBar { get; }
Property Value
|
RadScrollBarElement
|
Implements
VisibleSize
Gets or sets the dimensions of the visible worksheet area in rows and columns.
Declaration
public SizeI VisibleSize { get; set; }
Property Value
|
SizeI
|
Workbook
Gets or sets the workbook that contains all worksheets and spreadsheet data.
Declaration
public Workbook Workbook { get; set; }
Property Value
|
Workbook
|
WorksheetEditorContextMenu
Gets or sets the context menu displayed when right-clicking within the worksheet editor area.
Declaration
public RadContextMenu WorksheetEditorContextMenu { get; set; }
Property Value
|
RadContextMenu
|
WorksheetUILayersBuilder
Gets or sets the builder responsible for creating and managing worksheet UI layers.
Declaration
public WorksheetUILayersBuilder WorksheetUILayersBuilder { get; set; }
Property Value
|
WorksheetUILayersBuilder
|
Methods
ArrangeOverride(SizeF)
Arranges the spreadsheet element and positions all child components within the final layout area.
Declaration
protected override SizeF ArrangeOverride(SizeF finalSize)
Parameters
|
System.Drawing.SizeF
finalSize
The final size that this element should use to arrange itself and its children. |
Returns
|
System.Drawing.SizeF
The actual size used by the element. |
Overrides
BeginUndoGroup()
Begins an undo group that allows multiple operations to be undone as a single action. Use in conjunction with EndUndoGroup() to group related operations.
Declaration
public void BeginUndoGroup()
CancelUndoGroup()
Cancels the currently active undo group, discarding all operations that would have been grouped since the last call to BeginUndoGroup().
Declaration
public void CancelUndoGroup()
CreateChildElements()
Creates the child elements that make up the spreadsheet's visual structure. Initializes the formula bar, content presenter, scroll bars, sheet selector, and other UI components.
Declaration
protected override void CreateChildElements()
Overrides
CreateDefaultWorkbookContextMenu()
DpiScaleChanged(SizeF)
Updates the element and its children to account for DPI scaling changes. Ensures that the spreadsheet and its components render correctly at different DPI settings.
Declaration
public override void DpiScaleChanged(SizeF scaleFactor)
Parameters
|
System.Drawing.SizeF
scaleFactor
The new DPI scale factor to apply. |
Overrides
EndUndoGroup()
Ends the currently active undo group, finalizing the grouping of operations since the last call to BeginUndoGroup().
Declaration
public void EndUndoGroup()
EnsureDefaultContextMenu()
Declaration
protected virtual void EnsureDefaultContextMenu()
InvalidateLayout()
Invalidates the layout.
Declaration
public void InvalidateLayout()
MeasureOverride(SizeF)
Measures the desired size of the spreadsheet element and its child components.
Declaration
protected override SizeF MeasureOverride(SizeF availableSize)
Parameters
|
System.Drawing.SizeF
availableSize
The available size that this element can use. |
Returns
|
System.Drawing.SizeF
The desired size of this element based on its content. |
Overrides
OnActiveSheetChanged()
OnActiveSheetEditorChanged()
Raises the ActiveSheetEditorChanged event.
Declaration
protected virtual void OnActiveSheetEditorChanged()
OnBeforeOpenFile(OpenFileDialogEventArgs)
Raises the BeforeOpenFile event.
Declaration
protected virtual void OnBeforeOpenFile(OpenFileDialogEventArgs args)
Parameters
|
OpenFileDialogEventArgs
args
Event arguments that hold the event data. |
OnBeforeSaveFile(SaveFileDialogEventArgs)
Raises the BeforeSaveFile event.
Declaration
protected virtual void OnBeforeSaveFile(SaveFileDialogEventArgs args)
Parameters
|
SaveFileDialogEventArgs
args
Event arguments that hold the event data. |
OnContextMenuShowing(Object, SpreadsheetContextMenuOpeningEventArgs)
Raises the ContextMenuShowing event.
Declaration
protected virtual void OnContextMenuShowing(object sender, SpreadsheetContextMenuOpeningEventArgs e)
Parameters
|
System.Object
sender
The object that initiated the event. |
|
SpreadsheetContextMenuOpeningEventArgs
e
Event arguments containing context menu information. |
OnMessageShowing(MessageShowingEventArgs)
Raises the MessageShowing event.
Declaration
protected virtual void OnMessageShowing(MessageShowingEventArgs args)
Parameters
|
MessageShowingEventArgs
args
The event arguments containing message information. |
OnMouseDown(MouseEventArgs)
Raises the MouseDown event and handles right-click actions to show the context menu.
Declaration
protected override void OnMouseDown(MouseEventArgs e)
Parameters
|
System.Windows.Forms.MouseEventArgs
e
A MouseEventArgs that contains the event data. |
Overrides
OnTemplateApplying()
Called when the template is applying.
Declaration
protected virtual void OnTemplateApplying()
OnWorkbookChanged()
OnWorkbookChanging()
OnWorkbookCommandError(CommandErrorEventArgs)
Raises the WorkbookCommandError event.
Declaration
protected virtual void OnWorkbookCommandError(CommandErrorEventArgs args)
Parameters
|
CommandErrorEventArgs
args
The event arguments containing error information. |
OnWorkbookCommandExecuted(CommandExecutedEventArgs)
Raises the WorkbookCommandExecuted event.
Declaration
protected virtual void OnWorkbookCommandExecuted(CommandExecutedEventArgs args)
Parameters
|
CommandExecutedEventArgs
args
The event arguments containing command execution results. |
OnWorkbookCommandExecuting(CommandExecutingEventArgs)
Raises the WorkbookCommandExecuting event.
Declaration
protected virtual void OnWorkbookCommandExecuting(CommandExecutingEventArgs args)
Parameters
|
CommandExecutingEventArgs
args
The event arguments containing command execution details. |
Print(PrintWhatSettings, String, Boolean)
Prints the spreadsheet content using the specified print settings. Allows printing the active worksheet, a specific range of cells, or the entire workbook.
Declaration
public void Print(PrintWhatSettings printWhatSettings, string printDescription = null, bool showDialog = true)
Parameters
|
PrintWhatSettings
printWhatSettings
Settings that determine what content should be printed (worksheet, selection, etc.). |
|
System.String
printDescription
Optional description text that appears in the print preview and printed output. |
|
System.Boolean
showDialog
When true, displays the print dialog before printing; when false, prints directly with current settings. |
PrintPreview()
Shows the print preview dialog that allows the user to view how the spreadsheet will look when printed and make adjustments to print settings before printing.
Declaration
public void PrintPreview()
ProcessMouseWheel(MouseEventArgs, Boolean)
Processes the MouseWheel event for zooming and scrolling the spreadsheet. When Control key is pressed, zooms in or out; otherwise scrolls the worksheet vertically.
Declaration
public virtual bool ProcessMouseWheel(MouseEventArgs e, bool control)
Parameters
|
System.Windows.Forms.MouseEventArgs
e
The event arguments containing mouse wheel delta information. |
|
System.Boolean
control
True if Control key was pressed, false otherwise. |
Returns
|
System.Boolean
True if the event was handled and should not be processed further, false otherwise. |
ReceiveWeakEvent(Type, Object, EventArgs)
Receives events from the centralized event manager.
Declaration
public bool ReceiveWeakEvent(Type managerType, object sender, EventArgs e)
Parameters
|
System.Type
managerType
The type of the System.Windows.WeakEventManager calling this method. |
|
System.Object
sender
Object that originated the event. |
|
System.EventArgs
e
Event data. |
Returns
|
System.Boolean
true if the listener handled the event. It is considered an error by the System.Windows.WeakEventManager handling in WPF to register a listener for an event that the listener does not handle. Regardless, the method should return false if it receives an event that it does not recognize or handle. |
Redo()
Redoes the most recently undone operation or group of operations in the spreadsheet.
Declaration
public bool Redo()
Returns
|
System.Boolean
True if the redo operation succeeded; otherwise, false. |
SetDarkIcons()
Declaration
protected virtual void SetDarkIcons()
SetHorizontalOffset(Double)
Sets the horizontal scroll position of the active sheet editor. Controls the horizontal scrolling position of the worksheet viewport.
Declaration
public void SetHorizontalOffset(double offset)
Parameters
|
System.Double
offset
The horizontal offset value to set in pixels. |
SetStandardIcons()
Declaration
protected virtual void SetStandardIcons()
SetVerticalOffset(Double)
Sets the vertical scroll position of the active sheet editor. Controls the vertical scrolling position of the worksheet viewport.
Declaration
public void SetVerticalOffset(double offset)
Parameters
|
System.Double
offset
The vertical offset value to set in pixels. |
ShowContextMenu(MouseEventArgs)
Declaration
protected virtual void ShowContextMenu(MouseEventArgs e)
Parameters
|
System.Windows.Forms.MouseEventArgs
e
|
Undo()
Undoes the most recent operation or group of operations in the spreadsheet.
Declaration
public bool Undo()
Returns
|
System.Boolean
True if the undo operation succeeded; otherwise, false. |
UpdateIconSet()
Updates the icon set used throughout the spreadsheet interface to match the current theme. Ensures proper icon contrast when switching between light and dark themes.
Declaration
public virtual void UpdateIconSet()
Events
ActiveSheetChanged
Occurs when the active sheet changes to a different worksheet within the workbook.
Declaration
public event EventHandler ActiveSheetChanged
Event Type
|
System.EventHandler
|
ActiveSheetEditorChanged
Occurs when the active sheet editor changes to a different editor implementation.
Declaration
public event EventHandler ActiveSheetEditorChanged
Event Type
|
System.EventHandler
|
BeforeOpenFile
Occurs before a file is opened, before the open file dialog is shown.
Declaration
public event EventHandler<OpenFileDialogEventArgs> BeforeOpenFile
Event Type
|
System.EventHandler<OpenFileDialogEventArgs>
|
Remarks
Subscribe to this event to customize the OpenFileDialog properties (like Filter, InitialDirectory, etc.) before it is displayed to the user. Handlers can also cancel the open file operation by setting the Cancel property of the event arguments to true.
BeforeSaveFile
Occurs before the file is saved, before the save file dialog is shown.
Declaration
public event EventHandler<SaveFileDialogEventArgs> BeforeSaveFile
Event Type
|
System.EventHandler<SaveFileDialogEventArgs>
|
Remarks
Subscribe to this event to customize the SaveFileDialog properties (like Filter, InitialDirectory, etc.) before it is displayed to the user. Handlers can also cancel the open file operation by setting the Cancel property of the event arguments to true.
ContextMenuShowing
Occurs when the spreadsheet context menu is about to be shown. Allows customization of the context menu items before they are displayed.
Declaration
public event SpreadsheetContextMenuOpeningEventHandler ContextMenuShowing
Event Type
|
SpreadsheetContextMenuOpeningEventHandler
|
MessageShowing
Occurs when a message or warning needs to be displayed to the user.
Declaration
public event EventHandler<MessageShowingEventArgs> MessageShowing
Event Type
|
System.EventHandler<MessageShowingEventArgs>
|
WorkbookChanged
Occurs after the workbook has been changed to a different workbook instance.
Declaration
public event EventHandler WorkbookChanged
Event Type
|
System.EventHandler
|
WorkbookChanging
Occurs before the workbook is changed, allowing for preparation or validation before the change.
Declaration
public event EventHandler WorkbookChanging
Event Type
|
System.EventHandler
|
WorkbookCommandError
Occurs when an error occurs during the execution of a workbook command.
Declaration
public event EventHandler<CommandErrorEventArgs> WorkbookCommandError
Event Type
|
System.EventHandler<CommandErrorEventArgs>
|
WorkbookCommandExecuted
Occurs after a workbook command has been successfully executed.
Declaration
public event EventHandler<CommandExecutedEventArgs> WorkbookCommandExecuted
Event Type
|
System.EventHandler<CommandExecutedEventArgs>
|
WorkbookCommandExecuting
Occurs before a workbook command is executed, allowing for cancellation or modification of the command.
Declaration
public event EventHandler<CommandExecutingEventArgs> WorkbookCommandExecuting
Event Type
|
System.EventHandler<CommandExecutingEventArgs>
|
WorkbookContentChanged
Occurs when any content within the workbook has been modified, such as cell values, formatting, or structure changes.
Declaration
public event EventHandler WorkbookContentChanged
Event Type
|
System.EventHandler
|