NativeExcel for .Net Developer's Reference

IBorders.Item Property

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]
returnValue = IBordersObject.Item( borderindex );
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.

book.Worksheets[1].Range["A1:G1"].Borders[XlBordersIndex.xlEdgeBottom].Color = Color.FromArgb(255, 0, 0);
book.Worksheets(1).Range("A1:G1").Borders(XlBordersIndex.xlEdgeBottom).Color = Color.FromArgb(255, 0, 0)
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.
IBorder border = book.Worksheets["Sheet1"].Range["A1:D4"].Borders[XlBordersIndex.xlAraund];
border.ColorIndex = 3;
border.Weight = XlBorderWeight.xlThick;
Dim border As IBorder = book.Worksheets("Sheet1").Range("A1:D4").Borders(XlBordersIndex.xlAraund)
border.ColorIndex = 3
border.Weight = XlBorderWeight.xlThick
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;

See Also

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