XmlMappedRange.BorderAround 方法

XmlMappedRange 控件添加一个边框,并设置新边框的 ColorLineStyleWeight 属性。

命名空间:  Microsoft.Office.Tools.Excel
程序集:  Microsoft.Office.Tools.Excel(在 Microsoft.Office.Tools.Excel.dll 中)

语法

声明
Function BorderAround ( _
    LineStyle As Object, _
    Weight As XlBorderWeight, _
    ColorIndex As XlColorIndex, _
    Color As Object _
) As Object
Object BorderAround(
    Object LineStyle,
    XlBorderWeight Weight,
    XlColorIndex ColorIndex,
    Object Color
)

参数

  • Color
    类型:System.Object
    边框颜色,采用 RGB 值的形式。

返回值

类型:System.Object

备注

必须指定 ColorIndex 或 Color,但是不能同时指定二者。

可以指定 LineStyle 或 Weight,但是不能同时指定二者。 如果没有指定任何参数,则 Microsoft Office Excel 将使用默认的线型和粗细。

此方法绘制 XmlMappedRange 控件的大纲而不填充该控件。

若要清除边框,可以将 XmlMappedRange 控件的 LineStyle 属性设置为 xlLineStyleNone

可选参数

有关可选参数的信息,请参见Office 解决方案中的可选参数

示例

下面的代码示例使用 BorderAround 方法将粗边框应用于 XmlMappedRange 周围。 然后该示例提示用户使用 ClearFormats 方法清除该边框。 此代码示例假定当前工作表包含一个名为 CustomerLastNameCell 的 XmlMappedRange

Private Sub SetBorder()
    Me.CustomerLastNameCell.BorderAround( _
        Weight:=Excel.XlBorderWeight.xlThick, _
        ColorIndex:=Excel.XlColorIndex.xlColorIndexAutomatic)

    If MessageBox.Show("Clear the border?", "Test", MessageBoxButtons.YesNo) = _
        DialogResult.Yes Then
        Me.CustomerLastNameCell.ClearFormats()
    End If
End Sub
private void SetBorder()
{
    this.CustomerLastNameCell.BorderAround(missing, 
        Excel.XlBorderWeight.xlThick, 
        Excel.XlColorIndex.xlColorIndexAutomatic, missing);

    if (MessageBox.Show("Clear the border?", "Test",
        MessageBoxButtons.YesNo) == DialogResult.Yes)
    {
        this.CustomerLastNameCell.ClearFormats();
    }
}

.NET Framework 安全性

请参见

参考

XmlMappedRange 接口

Microsoft.Office.Tools.Excel 命名空间