NativeExcel for .Net Developer's Reference

IBorders.ColorIndex Property

Returns or sets the color index of the borders.

[Visual Basic]
Property ColorIndex As Integer
[C#]
int ColorIndex { get; set; }
[C++]
__property int get_ColorIndex();
__property void set_ColorIndex(int );
[JScript]
function get ColorIndex() : int
function set ColorIndex(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;
[Visual Basic]
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;
[Visual Basic]
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;
[Visual Basic]
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