Export (0) Print
Expand All
Expand Minimize

NamedRange.Top Property

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

Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in microsoft.office.tools.excel.dll)

public Object Top { get; }

Property Value

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

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

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.

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 + ".");
}

Show:
© 2014 Microsoft