NamedRange.VerticalAlignment Property (2007 System)
Gets or sets the vertical alignment of the NamedRange control.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)
Syntax
'Declaration
<BrowsableAttribute(False)> _
Public Property VerticalAlignment As Object
'Usage
Dim instance As NamedRange
Dim value As Object
value = instance.VerticalAlignment
instance.VerticalAlignment = value
[BrowsableAttribute(false)]
public Object VerticalAlignment { get; set; }
[BrowsableAttribute(false)]
public:
property Object^ VerticalAlignment {
Object^ get ();
void set (Object^ value);
}
public function get VerticalAlignment () : Object
public function set VerticalAlignment (value : Object)
Property Value
Type: System.Object
One of the XlVAlign values.
Remarks
Some of the XlVAlign values might not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.
Examples
The following code example demonstrates how to set a variety of formatting and display characteristics of a NamedRange control named NamedRange1. In particular, this example sets the VerticalAlignment property to xlVAlignCenter so that the contents of the range are centered vertically within the bounds of each cell.
This example is for a document-level customization.
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
private void SetRangeFormats()
{
Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
this.Controls.AddNamedRange(this.Range["A1", "A5"],
"namedRange1");
namedRange1.NoteText("This is a Formatting test", missing, missing);
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, missing);
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();
}
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.