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
)

參數

傳回值

型別: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);

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

.NET Framework 安全性

請參閱

參考

XmlMappedRange 介面

Microsoft.Office.Tools.Excel 命名空間