New to Telerik Document ProcessingStart a free 30-day trial

Abstract base for range-based selections in worksheets, providing property access and modification methods for formatting, borders, and values across one or more cell ranges.

Definition

Namespace:Telerik.Windows.Documents.Spreadsheet.Model

Assembly:Telerik.Windows.Documents.Spreadsheet.dll

Syntax:

C#
public abstract class SelectionBase

Inheritance: objectSelectionBase

Derived Classes: CellSelectionRowColumnSelectionBase

Methods

Suspends layout recalculation and starts an undo group, enabling efficient batch modifications across the selection.

C#
protected void BeginUpdate()

Clears content, formatting, or both from the selection based on the specified clear type.

C#
public void Clear(ClearType type)
Parameters:typeClearType

The type of clear.

Removes all borders from the selection, including outer, inner, and diagonal borders.

C#
public void ClearBorders()

Removes the background fill from the selection, reverting to no fill.

C#
public void ClearFill()

Removes the font family from the selection, reverting to the default font.

C#
public void ClearFontFamily()

Removes the font size from the selection, reverting to the default size.

C#
public void ClearFontSize()

Removes the text color from the selection, reverting to the default color.

C#
public void ClearForeColor()

Removes the number format from the selection, reverting to the default format.

C#
public void ClearFormat()

Removes the horizontal alignment from the selection, reverting to the default alignment.

C#
public void ClearHorizontalAlignment()

Removes the indentation from the selection, reverting to zero indent.

C#
public void ClearIndent()

Removes the bold formatting from the selection, reverting to the default weight.

C#
public void ClearIsBold()

Removes the italic formatting from the selection, reverting to the default style.

C#
public void ClearIsItalic()

Removes the lock setting from the selection, reverting to the default locked state.

C#
public void ClearIsLocked()

Removes the strikethrough formatting from the selection, reverting to no strikethrough.

C#
public void ClearIsStrikethrough()

Removes the text wrapping setting from the selection, reverting to the default behavior.

C#
public void ClearIsWrapped()

Removes the named style reference from the selection, reverting to the default style.

C#
public void ClearStyleName()

Removes the text rotation from the selection, reverting to zero degrees.

C#
public void ClearTextRotation()

Removes the underline style from the selection, reverting to no underline.

C#
public void ClearUnderline()

Removes the vertical alignment from the selection, reverting to the default alignment.

C#
public void ClearVerticalAlignment()

Removes the vertical text alignment from the selection, reverting to baseline.

C#
public void ClearVerticalTextAlignment()

Decreases the indentation level by one for the selection, ensuring compatible horizontal alignment and stopping at zero.

C#
public void DecreaseIndent()

Resumes layout recalculation and closes the undo group, completing the batch modification initiated by BeginUpdate.

C#
protected void EndUpdate()

Executes the specified action on each range in the selection without suspending updates.

C#
protected void ExecuteForEachRange(Action<CellRange> action)
Parameters:actionAction<CellRange>

The action.

Executes the specified action on each provided range, optionally checking a predicate before proceeding, and returns whether all ranges passed the predicate.

C#
protected bool ExecuteForEachRange(IEnumerable<CellRange> cellRanges, Action<CellRange> action, Predicate<CellRange> canExecute = null)
Parameters:cellRangesIEnumerable<CellRange>

The cell ranges.

actionAction<CellRange>

The action.

canExecutePredicate<CellRange>

The can execute.

Returns:

bool

Executes the specified action on each range in the selection within a suspended-update context.

C#
protected void ExecuteForEachRangeInsideBeginEndUpdate(Action<CellRange> action)
Parameters:actionAction<CellRange>

The action.

Executes the specified action on each provided range within a suspended-update context, optionally checking a predicate before proceeding, and returns whether all ranges passed the predicate.

C#
protected bool ExecuteForEachRangeInsideBeginEndUpdate(IEnumerable<CellRange> cellRanges, Action<CellRange> action, Predicate<CellRange> canExecute = null)
Parameters:cellRangesIEnumerable<CellRange>

The cell ranges.

actionAction<CellRange>

The action.

canExecutePredicate<CellRange>

The can execute.

Returns:

bool

Retrieves all border styles applied to the selection, including outer, inner, and diagonal borders, resolving conflicts by priority.

C#
public CellBorders GetBorders()
Returns:

CellBorders

The cell borders.

Retrieves the background fill applied to the selection, or an indeterminate state if fills differ.

C#
public RangePropertyValue<IFill> GetFill()
Returns:

RangePropertyValue<IFill>

The fill value for the selection.

Retrieves the font family applied to the selection, which may reference a theme font or explicit typeface.

C#
public RangePropertyValue<ThemableFontFamily> GetFontFamily()
Returns:

RangePropertyValue<ThemableFontFamily>

The font family for the selection.

Retrieves the font size in device-independent units from the selection.

C#
public RangePropertyValue<double> GetFontSize()
Returns:

RangePropertyValue<double>

The font size for the selection.

Retrieves the text color applied to the selection, which may reference a theme color or explicit RGB value.

C#
public RangePropertyValue<ThemableColor> GetForeColor()
Returns:

RangePropertyValue<ThemableColor>

The font color for the selection.

Retrieves the number format pattern applied to the selection, or an indeterminate state if formats differ.

C#
public RangePropertyValue<CellValueFormat> GetFormat()
Returns:

RangePropertyValue<CellValueFormat>

The format for the selection.

Retrieves the horizontal text alignment applied to the selection.

C#
public RangePropertyValue<RadHorizontalAlignment> GetHorizontalAlignment()
Returns:

RangePropertyValue<RadHorizontalAlignment>

The horizontal alignment for the selection.

Retrieves the text indentation level applied to the selection, measured in indent units.

C#
public RangePropertyValue<int> GetIndent()
Returns:

RangePropertyValue<int>

The indent for the selection.

Checks whether bold formatting is applied to the selection.

C#
public RangePropertyValue<bool> GetIsBold()
Returns:

RangePropertyValue<bool>

The value indicating whether the font is bold for the selection.

Checks whether italic formatting is applied to the selection.

C#
public RangePropertyValue<bool> GetIsItalic()
Returns:

RangePropertyValue<bool>

The value indicating whether the font is italic for the selection.

Checks whether the selection is locked for editing when worksheet protection is enabled.

C#
public RangePropertyValue<bool> GetIsLocked()
Returns:

RangePropertyValue<bool>

The value indicating whether the selection is locked.

Checks whether strikethrough formatting is applied to the selection.

C#
public RangePropertyValue<bool> GetIsStrikethrough()
Returns:

RangePropertyValue<bool>

The value indicating whether the font is strikethrough for the selection.

Checks whether text wrapping is enabled for the selection.

C#
public RangePropertyValue<bool> GetIsWrapped()
Returns:

RangePropertyValue<bool>

The value indicating whether text wrapping is used.

Retrieves a property value from the specified ranges, returning either a consistent value or an indeterminate state if values differ across ranges.

C#
protected RangePropertyValue<T> GetPropertyValue<T>(Func<CellRange, RangePropertyValue<T>> getRangePropertyValue, IEnumerable<CellRange> cellRanges, T defaultValue)
Parameters:getRangePropertyValueFunc<CellRange, RangePropertyValue<T>>

The get range property value.

cellRangesIEnumerable<CellRange>

The cell ranges.

defaultValueT

The default value.

Returns:

RangePropertyValue<T>

Retrieves the named cell style applied to the selection, or an indeterminate state if styles differ.

C#
public RangePropertyValue<string> GetStyleName()
Returns:

RangePropertyValue<string>

The name of the style for the selection.

Retrieves the text rotation angle applied to the selection, measured in degrees from -90 to 90.

C#
public RangePropertyValue<int> GetTextRotation()
Returns:

RangePropertyValue<int>

The text rotation degree for the selection in range -90 to 90.

Finds and returns the top-left cell index across all ranges in the selection.

C#
protected CellIndex GetTopLeftCellIndex()
Returns:

CellIndex

Retrieves the underline style applied to the selection.

C#
public RangePropertyValue<UnderlineType> GetUnderline()
Returns:

RangePropertyValue<UnderlineType>

The underline property for the selection.

Retrieves the vertical text alignment applied to the selection.

C#
public RangePropertyValue<RadVerticalAlignment> GetVerticalAlignment()
Returns:

RangePropertyValue<RadVerticalAlignment>

The vertical alignment for the selection.

Checks the vertical text alignment (none, superscript, or subscript) applied to the selection.

C#
public RangePropertyValue<VerticalTextAlignment> GetVerticalTextAlignment()
Returns:

RangePropertyValue<VerticalTextAlignment>

The vertical text alignment for the selection.

Increases the indentation level by one for the selection, ensuring compatible horizontal alignment and respecting the maximum indent limit.

C#
public void IncreaseIndent()

Applies the specified border configuration to the selection, supporting outer, inner, and diagonal borders.

C#
public virtual void SetBorders(CellBorders value)
Parameters:valueCellBorders

The value.

Applies the specified background fill (solid, pattern, or gradient) to the selection.

C#
public void SetFill(IFill value)
Parameters:valueIFill

The value.

Applies the specified font family to the selection, supporting both theme-based and explicit font references.

C#
public void SetFontFamily(ThemableFontFamily value)
Parameters:valueThemableFontFamily

The value.

Applies the specified font size to the selection, which must be between 1 and 409 points.

C#
public void SetFontSize(double value)
Parameters:valuedouble

The value.

Applies the specified text color to the selection, supporting both theme-based and explicit color references.

C#
public void SetForeColor(ThemableColor value)
Parameters:valueThemableColor

The value.

Applies the specified number format pattern to the selection and updates cell values to respect the new format.

C#
public void SetFormat(CellValueFormat value)
Parameters:valueCellValueFormat

The value.

Applies the specified horizontal alignment to the selection, clearing indent if the alignment is incompatible.

C#
public void SetHorizontalAlignment(RadHorizontalAlignment value)
Parameters:valueRadHorizontalAlignment

The value.

Applies the specified indentation level to the selection, which must be between 0 and 250, and ensures compatible horizontal alignment.

C#
public void SetIndent(int value)
Parameters:valueint

The value.

Applies or removes bold formatting on the selection.

C#
public void SetIsBold(bool value)
Parameters:valuebool

The value.

Applies or removes italic formatting on the selection.

C#
public void SetIsItalic(bool value)
Parameters:valuebool

The value.

Locks or unlocks the selection for editing when worksheet protection is enabled.

C#
public void SetIsLocked(bool value)
Parameters:valuebool

The value.

Applies or removes strikethrough formatting on the selection.

C#
public void SetIsStrikethrough(bool value)
Parameters:valuebool

The value.

Enables or disables text wrapping for the selection.

C#
public void SetIsWrapped(bool value)
Parameters:valuebool

The value.

Applies the specified named cell style to the selection, clearing locally-set properties that conflict with the style definition.

C#
public void SetStyleName(string value)
Parameters:valuestring

The value.

Applies the specified rotation angle to the selection, which must be between -90 and 90 degrees.

C#
public void SetTextRotation(int value)
Parameters:valueint

The rotation degree in the range -90 to 90.

Applies the specified underline style to the selection.

C#
public void SetUnderline(UnderlineType value)
Parameters:valueUnderlineType

The value.

Applies the specified vertical alignment to the selection.

C#
public void SetVerticalAlignment(RadVerticalAlignment value)
Parameters:valueRadVerticalAlignment

The value.

Applies vertical text alignment (none, superscript, or subscript) to the selection.

C#
public void SetVerticalTextAlignment(VerticalTextAlignment value)
Parameters:valueVerticalTextAlignment

The value.

Properties

The collection of cell ranges included in this selection.

C#
public IEnumerable<CellRange> CellRanges { get; }
Property Value:

The cell ranges.

The worksheet containing this selection.

C#
public Worksheet Worksheet { get; }
Property Value:

The worksheet.

In this article
DefinitionMethodsBeginUpdate()Clear(ClearType)ClearBorders()ClearFill()ClearFontFamily()ClearFontSize()ClearForeColor()ClearFormat()ClearHorizontalAlignment()ClearIndent()ClearIsBold()ClearIsItalic()ClearIsLocked()ClearIsStrikethrough()ClearIsWrapped()ClearStyleName()ClearTextRotation()ClearUnderline()ClearVerticalAlignment()ClearVerticalTextAlignment()DecreaseIndent()EndUpdate()ExecuteForEachRange(Action<CellRange>)ExecuteForEachRange(IEnumerable<CellRange>, Action<CellRange>, Predicate<CellRange>)ExecuteForEachRangeInsideBeginEndUpdate(Action<CellRange>)ExecuteForEachRangeInsideBeginEndUpdate(IEnumerable<CellRange>, Action<CellRange>, Predicate<CellRange>)GetBorders()GetFill()GetFontFamily()GetFontSize()GetForeColor()GetFormat()GetHorizontalAlignment()GetIndent()GetIsBold()GetIsItalic()GetIsLocked()GetIsStrikethrough()GetIsWrapped()GetPropertyValue<T>(Func<CellRange, RangePropertyValue<T>>, IEnumerable<CellRange>, T)GetStyleName()GetTextRotation()GetTopLeftCellIndex()GetUnderline()GetVerticalAlignment()GetVerticalTextAlignment()IncreaseIndent()SetBorders(CellBorders)SetFill(IFill)SetFontFamily(ThemableFontFamily)SetFontSize(double)SetForeColor(ThemableColor)SetFormat(CellValueFormat)SetHorizontalAlignment(RadHorizontalAlignment)SetIndent(int)SetIsBold(bool)SetIsItalic(bool)SetIsLocked(bool)SetIsStrikethrough(bool)SetIsWrapped(bool)SetStyleName(string)SetTextRotation(int)SetUnderline(UnderlineType)SetVerticalAlignment(RadVerticalAlignment)SetVerticalTextAlignment(VerticalTextAlignment)PropertiesCellRangesWorksheet
Not finding the help you need?
Contact Support