officefileapi-devexpress-dot-spreadsheet-dot-cellrange-dot-setinsideborders-x28-system-dot-drawing-dot-color-devexpress-dot-spreadsheet-dot-borderlinestyle-x29.md
Sets all inside borders of the cell range.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
void SetInsideBorders(
Color color,
BorderLineStyle style
)
Sub SetInsideBorders(
color As Color,
style As BorderLineStyle
)
| Name | Type | Description |
|---|---|---|
| color | Color |
A Color value specifying the line color of borders.
| | style | BorderLineStyle |
A BorderLineStyle enumeration member specifying the line style of borders.
|
Use the SetInsideBorders method to set all borders within a range of cells.
To specify other sets of borders (e.g., outside, vertical or horizontal borders) or each particular border (e.g., bottom, top, left or right), use the corresponding properties and methods of the Borders object. For example, to specify borders around an entire range of cells, call the Borders.SetOutsideBorders method. To set both inside and outside borders of a range in one step, call the Borders.SetAllBorders method.
Access and modify the Borders object within the CellRange.BeginUpdateFormatting - CellRange.EndUpdateFormatting paired method calls. For details, refer to the How to: Add and Remove Cell Borders and How to: Format a Cell or Range of Cells documents.
To share the same cell border settings between multiple cell ranges in one step, apply a style via the CellRange.Style property.
This example demonstrates how to specify different borders for individual cells and ranges of cells by modifying the Borders object.
Worksheet worksheet = workbook.Worksheets[0];
// Set each particular border for the cell.
Cell cellB2 = worksheet.Cells["B2"];
Borders cellB2Borders = cellB2.Borders;
cellB2Borders.LeftBorder.LineStyle = BorderLineStyle.MediumDashDot;
cellB2Borders.LeftBorder.Color = Color.Pink;
cellB2Borders.TopBorder.LineStyle = BorderLineStyle.MediumDashDotDot;
cellB2Borders.TopBorder.Color = Color.HotPink;
cellB2Borders.RightBorder.LineStyle = BorderLineStyle.MediumDashed;
cellB2Borders.RightBorder.Color = Color.DeepPink;
cellB2Borders.BottomBorder.LineStyle = BorderLineStyle.Medium;
cellB2Borders.BottomBorder.Color = Color.Red;
// Set all borders for cells.
Cell cellC4 = worksheet.Cells["C4"];
cellC4.Borders.SetAllBorders(Color.Orange, BorderLineStyle.MediumDashed);
Cell cellD6 = worksheet.Cells["D6"];
cellD6.Borders.SetOutsideBorders(Color.Gold, BorderLineStyle.Double);
// Set all borders for the range of cells in one step.
CellRange range1 = worksheet.Range["B8:F13"];
range1.Borders.SetAllBorders(Color.Green, BorderLineStyle.Double);
// Set all inside and outside borders separately for the range of cells.
CellRange range2 = worksheet.Range["C15:F18"];
range2.SetInsideBorders(Color.SkyBlue, BorderLineStyle.MediumDashed);
range2.Borders.SetOutsideBorders(Color.DeepSkyBlue, BorderLineStyle.Medium);
// Set all horizontal and vertical borders separately for the range of cells.
CellRange range3 = worksheet.Range["D21:F23"];
Formatting range3Formatting = range3.BeginUpdateFormatting();
Borders range3Borders = range3Formatting.Borders;
range3Borders.InsideHorizontalBorders.LineStyle = BorderLineStyle.MediumDashDot;
range3Borders.InsideHorizontalBorders.Color = Color.DarkBlue;
range3Borders.InsideVerticalBorders.LineStyle = BorderLineStyle.MediumDashDotDot;
range3Borders.InsideVerticalBorders.Color = Color.Blue;
range3.EndUpdateFormatting(range3Formatting);
// Set each particular border for the range of cell.
CellRange range4 = worksheet.Range["E25:F26"];
Formatting range4Formatting = range4.BeginUpdateFormatting();
Borders range4Borders = range4Formatting.Borders;
range4Borders.SetOutsideBorders(Color.Black, BorderLineStyle.Thick);
range4Borders.LeftBorder.Color = Color.Violet;
range4Borders.TopBorder.Color = Color.Violet;
range4Borders.RightBorder.Color = Color.DarkViolet;
range4Borders.BottomBorder.Color = Color.DarkViolet;
range4.EndUpdateFormatting(range4Formatting);
Dim worksheet As Worksheet = workbook.Worksheets(0)
' Set each particular border for the cell.
Dim cellB2 As Cell = worksheet.Cells("B2")
Dim cellB2Borders As Borders = cellB2.Borders
cellB2Borders.LeftBorder.LineStyle = BorderLineStyle.MediumDashDot
cellB2Borders.LeftBorder.Color = Color.Pink
cellB2Borders.TopBorder.LineStyle = BorderLineStyle.MediumDashDotDot
cellB2Borders.TopBorder.Color = Color.HotPink
cellB2Borders.RightBorder.LineStyle = BorderLineStyle.MediumDashed
cellB2Borders.RightBorder.Color = Color.DeepPink
cellB2Borders.BottomBorder.LineStyle = BorderLineStyle.Medium
cellB2Borders.BottomBorder.Color = Color.Red
' Set all borders for cells.
Dim cellC4 As Cell = worksheet.Cells("C4")
cellC4.Borders.SetAllBorders(Color.Orange, BorderLineStyle.MediumDashed)
Dim cellD6 As Cell = worksheet.Cells("D6")
cellD6.Borders.SetOutsideBorders(Color.Gold, BorderLineStyle.Double)
' Set all borders for the range of cells in one step.
Dim range1 As CellRange = worksheet.Range("B8:F13")
range1.Borders.SetAllBorders(Color.Green, BorderLineStyle.Double)
' Set all inside and outside borders separately for the range of cells.
Dim range2 As CellRange = worksheet.Range("C15:F18")
range2.SetInsideBorders(Color.SkyBlue, BorderLineStyle.MediumDashed)
range2.Borders.SetOutsideBorders(Color.DeepSkyBlue, BorderLineStyle.Medium)
' Set all horizontal and vertical borders separately for the range of cells.
Dim range3 As CellRange = worksheet.Range("D21:F23")
Dim range3Formatting As Formatting = range3.BeginUpdateFormatting()
Dim range3Borders As Borders = range3Formatting.Borders
range3Borders.InsideHorizontalBorders.LineStyle = BorderLineStyle.MediumDashDot
range3Borders.InsideHorizontalBorders.Color = Color.DarkBlue
range3Borders.InsideVerticalBorders.LineStyle = BorderLineStyle.MediumDashDotDot
range3Borders.InsideVerticalBorders.Color = Color.Blue
range3.EndUpdateFormatting(range3Formatting)
' Set each particular border for the range of cell.
Dim range4 As CellRange = worksheet.Range("E25:F26")
Dim range4Formatting As Formatting = range4.BeginUpdateFormatting()
Dim range4Borders As Borders = range4Formatting.Borders
range4Borders.SetOutsideBorders(Color.Black, BorderLineStyle.Thick)
range4Borders.LeftBorder.Color = Color.Violet
range4Borders.TopBorder.Color = Color.Violet
range4Borders.RightBorder.Color = Color.DarkViolet
range4Borders.BottomBorder.Color = Color.DarkViolet
range4.EndUpdateFormatting(range4Formatting)
See Also