NamedRange.VerticalAlignment 属性

获取或设置 NamedRange 控件的垂直对齐方式。

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

语法

声明
Property VerticalAlignment As Object
Object VerticalAlignment { get; set; }

属性值

类型:System.Object
XlVAlign 值之一。

备注

某些 XlVAlign 值可能不可供您使用,根据语言支持 (如美国.. 英语),该您选择了或安装。

示例

下面的代码示例演示如何设置各种格式以及显示名为 NamedRange1 的 NamedRange 控件的特征。特别是,此示例将 VerticalAlignment 属性设置为 xlVAlignCenter,以便范围的内容在每个单元格的界限内垂直居中对齐。

此示例针对的是文档级自定义项。

' <Snippet37>
Private Sub SetRangeFormats()
    Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
        = Me.Controls.AddNamedRange(Me.Range("A1", "A5"), _
        "namedRange1")

    namedRange1.NoteText("This is a Formatting test", , )
    namedRange1.Value2 = "Martha"
    namedRange1.Font.Name = "Verdana"
    namedRange1.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter
    namedRange1.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter
    namedRange1.BorderAround(, Excel.XlBorderWeight.xlThick, _
        Excel.XlColorIndex.xlColorIndexAutomatic, )
    namedRange1.AutoFormat( _
        Excel.XlRangeAutoFormat.xlRangeAutoFormat3DEffects1, _
        True, False, True, False, True, True)

    If MessageBox.Show("Clear the formatting and notes?", _
        "Test", MessageBoxButtons.YesNo) = DialogResult.Yes Then
        namedRange1.ClearFormats()
        namedRange1.ClearNotes()
    End If
End Sub

' </Snippet35>
// <Snippet37>
private void SetRangeFormats()
{
    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1", "A5"],
        "namedRange1");

    namedRange1.NoteText("This is a Formatting test");
    namedRange1.Value2 = "Martha";
    namedRange1.Font.Name = "Verdana";
    namedRange1.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;
    namedRange1.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
    namedRange1.BorderAround(missing, Excel.XlBorderWeight.xlThick, 
        Excel.XlColorIndex.xlColorIndexAutomatic);
    namedRange1.AutoFormat(Excel.XlRangeAutoFormat.xlRangeAutoFormat3DEffects1,
        true, false, true, false, true, true);

    if (MessageBox.Show("Clear the formatting and notes?", "Test",
        MessageBoxButtons.YesNo) == DialogResult.Yes)
    {
        namedRange1.ClearFormats();
        namedRange1.ClearNotes();
    }
}
// </Snippet35>

.NET Framework 安全性

请参见

参考

NamedRange 接口

Microsoft.Office.Tools.Excel 命名空间