NativeExcel2 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]
DefaultPropertyReadOnlyItem(_
ByValborderindexAsXlBordersIndex_
)AsIBorder
[C#]
IBorderthis[
XlBordersIndexborderindex
]{get;}
[C++]
__propertyIBorder*get_Item(
XlBordersIndexborderindex
);
[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.

Example

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);
[VisualBasic]
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;
[VisualBasic]
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;

See Also

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