NativeExcel2 for .Net Developer's Reference

IBorders.ColorIndex Property

Returns or sets the color index of the borders.

[Visual Basic]
PropertyColorIndexAsInteger
[C#]
intColorIndex{get;set;}
[C++]
__propertyintget_ColorIndex();
__propertyvoidset_ColorIndex(int);
[JScript]
functiongetColorIndex():int
functionsetColorIndex(int);

Property Value

The color index of the specified borders. The color is specified as an index value into the current color palette, or as one of the XlColorIndex constants.

Example

This example sets the borders color of A1:D1 range.

[C#]
book.Worksheets[1].Range["A1:D1"].Borders.ColorIndex = 3;
[VisualBasic]
book.Worksheets(1).Range("A1:D1").Borders.ColorIndex = 3
[C++]
IRange* range = book->Worksheets->Item[1]->Range->Item[S"A1:D1"];
IBorders* borders = range->Borders;  
borders->ColorIndex = 3;
This example removes the borders of the cell A1.
[C#]
book.Worksheets[1].Range["A1"].Borders.ColorIndex = XlColorIndex.xlColorIndexNone;
[VisualBasic]
book.Worksheets(1).Range("A1").Borders.ColorIndex = XlColorIndex.xlColorIndexNone
[C++]
IRange* range = book->Worksheets->Item[1]->Range->Item[S"A1"];
IBorders* borders = range->Borders;  
borders->ColorIndex = XlColorIndex::xlColorIndexNone;
This example sets the borders color of A1:D1 range to Automatic.
[C#]
book.Worksheets[1].Range["A1:D1"].Borders.ColorIndex = XlColorIndex.xlColorIndexAutomatic;
[VisualBasic]
book.Worksheets(1).Range("A1:D1").Borders.ColorIndex = XlColorIndex.xlColorIndexAutomatic
[C++]
IRange* range = book->Worksheets->Item[1]->Range->Item[S"A1:D1"];
IBorders* borders = range->Borders;  
borders->ColorIndex = XlColorIndex::xlColorIndexAutomatic;

See Also

IBorders Interface | NativeExcel Namespace | IRange.Borders Property | IPalette Interface | IWorkbook.Colors Property | XlColorsIndex Class