NativeExcel for .Net Developer's Reference

IBorder.ColorIndex Property

Returns or sets the color of the border. The color is specified as an index value into the current color palette, or as the following XlColorIndex constant: xlColorIndexAutomatic, xlColorIndexNone. Read/write int.

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

Example

This example sets the color of the top edge border of A1:D1 range.

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

See Also

IBorder Interface | NativeExcel Namespace | XlBordersIndex Enumeration | XlColorIndex Class | IRange.Borders Property | IBorders Interface