Fill.PatternType Property
Gets or sets the cell background pattern.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v19.1.Core.dll
Declaration
Property Value
Type | Description |
---|---|
PatternType | A PatternType enumeration member that specifies the pattern for the cell shading. Default is None. |
Remarks
To specify the cell background characteristics, use the Fill.BackgroundColor, PatternType and Fill.PatternColor properties of the Fill object.
By default, the PatternType property is set to PatternType.None. When you set the Fill.BackgroundColor property, the PatternType property value is automatically changed to PatternType.Solid.
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 Range.BeginUpdateFormatting - Range.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.
Example
This example demonstrates how to format color characteristics (font and background colors) for an individual cell and range of cells.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/spreadsheet-document-server-api-e4339
// Format an individual cell.
worksheet.Cells["A1"].Font.Color = Color.Red;
worksheet.Cells["A1"].FillColor = Color.Yellow;
// Format a range of cells.
Range 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);
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the PatternType property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.