Fill Interface
Contains the cell background attributes.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v24.2.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
Declaration
Related API Members
The following members return Fill objects:
Remarks
The Fill object provides a set of properties that you can use to customize the cell background. The Fill.BackgroundColor property specifies the cell background color (it is also available via the CellRange.FillColor property of the cell or cell range object), the Fill.PatternType specifies the type of cell background pattern (the PatternType enumeration lists the available pattern types) and the Fill.PatternColor specifies the shade color for a cell.
The Fill.FillType property specifies whether a gradient effect is applied to the cell background. The Fill.Gradient property contains gradient settings. Note that if the Fill.BackgroundColor property is set to a non-empty value, gradient effects are not applicable.
To access the Fill object, use the Formatting.Fill property.
- To specify the background of an individual cell, access the Fill object using the cell’s Formatting.Fill property directly.
- To specify the background of a cell range, modify the Fill object within the CellRange.BeginUpdateFormatting - CellRange.EndUpdateFormatting method pair.
- To share the same background settings between multiple cells in one step, apply the style with the specified background to the required cells. To specify the cell style background, access the Style object from the IWorkbook.Styles collection and use this style’s Formatting.Fill property within the Formatting.BeginUpdate-Formatting.EndUpdate paired methods to access and modify the Fill object.
For examples on how to specify formatting for an individual cell and cell range or modify a style, refer to the How to: Format a Cell or Range of Cells or How to: Create or Modify a Style document.
To custom paint a cell background in the SpreadsheetControl, handle the SpreadsheetControl.CustomDrawCellBackground event.
Example
The following example specifies font and background colors for an individual cell and cell range:
using DevExpress.Spreadsheet;
using System.Drawing;
// ...
// Format an individual cell.
worksheet.Cells["A1"].Font.Color = Color.Red;
worksheet.Cells["A1"].FillColor = Color.Yellow;
// Format a cell range.
CellRange range = worksheet.Range["C3:D4"];
Formatting rangeFormatting = range.BeginUpdateFormatting();
rangeFormatting.Font.Color = Color.Blue;
rangeFormatting.Fill.BackgroundColor = Color.LightBlue;
rangeFormatting.Fill.PatternType = PatternType.LightHorizontal;
rangeFormatting.Fill.PatternColor = Color.Violet;
range.EndUpdateFormatting(rangeFormatting);