Returns an IBorder interface that represents one of the borders of a range.
[C#] In C#, this property is the indexer for the IBorders class.
[Visual Basic] Default Property ReadOnly Item( _ ByVal borderindex As XlBordersIndex _ ) As IBorder [C#] IBorder this[ XlBordersIndex borderindex ] { get; } [C++] __property IBorder* get_Item( XlBordersIndex borderindex ); [JScript] returnValue = IBordersObject.Item( borderindex ); -or- returnValue = IBordersObject( borderindex );
[JScript] In JScript, you can use the default indexed properties defined by a type, but you cannot explicitly define your own. However, specifying the expando attribute on a class automatically provides a default indexed property whose type is Object and whose index type is String.
The following example sets the color of the bottom border of cells A1:G1.
[C#]
book.Worksheets[1].Range["A1:G1"].Borders[XlBordersIndex.xlEdgeBottom].Color = Color.FromArgb(255, 0, 0);
[Visual Basic]
book.Worksheets(1).Range("A1:G1").Borders(XlBordersIndex.xlEdgeBottom).Color = Color.FromArgb(255, 0, 0)
[C++]
IRange* range = book->Worksheets->Item[1]->Range->Item[S"A1:G1"];
range->Borders->Item[XlBordersIndex::xlEdgeBottom]->Color = Color::FromArgb(255, 0, 0);
This example adds a thick red border around the range A1:D4 on Sheet1. [C#]
IBorder border = book.Worksheets["Sheet1"].Range["A1:D4"].Borders[XlBordersIndex.xlAraund];
border.ColorIndex = 3;
border.Weight = XlBorderWeight.xlThick;
[Visual Basic]
Dim border As IBorder = book.Worksheets("Sheet1").Range("A1:D4").Borders(XlBordersIndex.xlAraund)
border.ColorIndex = 3
border.Weight = XlBorderWeight.xlThick
[C++]
IRange* range = book->Worksheets->Item[S"Sheet1"]->Range->Item[S"A1:D4"];
IBorder* border = range->Borders->Item[XlBordersIndex::xlAraund];
border->ColorIndex = 3;
border->Weight = XlBorderWeight::xlThick;
IBorders Interface | NativeExcel Namespace | XlBordersIndex Enumeration | IBorder Interface | IRange.Borders Property