다음을 통해 공유


NamedRange.Top Property

Definition

Gets the distance, in points, from the top edge of row 1 (one) to the top edge of the NamedRange control.

public:
 property System::Object ^ Top { System::Object ^ get(); };
public object Top { get; }
member this.Top : obj
Public ReadOnly Property Top As Object

Property Value

The distance, in points, from the top edge of row 1 (one) to the top edge of the NamedRange control.

Examples

The following code example creates a NamedRange control. It then uses the Left and Top properties to display the distance from the left edge of column A to the left edge of the NamedRange, and the distance from the top of row 1 to the top edge of the NamedRange.

This example is for a document-level customization.

Microsoft.Office.Tools.Excel.NamedRange leftAndTopRange;
private void DisplayLeftAndTop()
{
    leftAndTopRange = this.Controls.AddNamedRange(
        this.Range["B4", "D6"], "addIndentRange");
    leftAndTopRange.Select();
    MessageBox.Show("The left border of the NamedRange control "
        + "is at " + this.leftAndTopRange.Left + 
        " and the top is at " + this.leftAndTopRange.Top + ".");
}
Private leftAndTopRange As Microsoft.Office.Tools.Excel.NamedRange

Private Sub DisplayLeftAndTop()
    leftAndTopRange = Me.Controls.AddNamedRange( _
        Me.Range("B4", "D6"), "addIndentRange")
    leftAndTopRange.Select()
    MessageBox.Show("The left border of the NamedRange " & _
        "control is at " & Me.leftAndTopRange.Left & _
        " and the top is at " & Me.leftAndTopRange.Top & ".")
End Sub

Remarks

If the NamedRange control is more than one row high, the top (lowest numbered) row in the NamedRange control is used.

Applies to