ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / Element Class / SetHeight Method
Double
Example

In This Topic
    SetHeight Method (Element)
    In This Topic
    Sets the height of the element. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void SetHeight( 
       double height
    )
    Public Sub SetHeight( _
       ByVal height As Double _
    ) 

    Parameters

    height
    Double
    Exceptions
    ExceptionDescription
    This method must be called within the lambda passed to QueuedTask.Run.
    This element requires its mapview to be active
    Remarks
    Placement for an element contained in graphics layer requires the mapview be active
    Example
    Element_GetSetHeight
    //Modify an element's hieght.
    
    //Perform on the worker thread
    await QueuedTask.Run(() =>
    {
      double elmHeight = element.GetHeight();
      elmHeight = 11;
    
      element.SetHeight(elmHeight); //You don't have to get to set; a shortcut would be: element.SetHieght(11);
    });
    Create_NorthArrow
    //Create a north arrow for a specific map frame and assign a north arrow style item.
    
    //Construct on the worker thread
    await QueuedTask.Run(() =>
    {
      //Reference a North Arrow in a style
      StyleProjectItem stylePrjItm = Project.Current.GetItems<StyleProjectItem>().FirstOrDefault(item => item.Name == "ArcGIS 2D");
      NorthArrowStyleItem naStyleItm = stylePrjItm.SearchNorthArrows("ArcGIS North 10")[0];
    
      //Build geometry
      Coordinate2D center = new Coordinate2D(7, 5.5);
    
      //Reference MF, create north arrow and add to layout 
      MapFrame mf = layout.FindElement("New Map Frame") as MapFrame;
      if (mf == null)
      {
        ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Map frame not found", "WARNING");
        return;
      }
      //At 2.x -
      //NorthArrow arrowElm = LayoutElementFactory.Instance.CreateNorthArrow(layout, center, mf, naStyleItm);
      //arrowElm.SetName("New North Arrow");
      //arrowElm.SetHeight(1.75);
      //arrowElm.SetX(7);
      //arrowElm.SetY(6);
    
      var naInfo = new NorthArrowInfo()
      {
        MapFrameName = mf.Name,
        NorthArrowStyleItem = naStyleItm
      };
    
      var arrowElm = ElementFactory.Instance.CreateMapSurroundElement(
                                layout, center.ToMapPoint(), naInfo, "New North Arrow") as NorthArrow;
      arrowElm.SetHeight(1.75);
      arrowElm.SetX(7);
      arrowElm.SetY(6);
    });
    Create North Arrow From StyleItem 2
    //Must be on QueuedTask.Run(() => { ...
    
    //Build geometry
    Coordinate2D center = new Coordinate2D(7, 5.5);
    
    //Reference a North Arrow in a style
    StyleProjectItem stylePrjItm = Project.Current.GetItems<StyleProjectItem>()
                                   .FirstOrDefault(item => item.Name == "ArcGIS 2D");
    NorthArrowStyleItem naStyleItm = stylePrjItm.SearchNorthArrows(
                                           "ArcGIS North 10")[0];
    
    //Reference MF, create north arrow and add to layout 
    //var mf = container.FindElement("New Map Frame") as MapFrame;
    var mf = layout.FindElement(MapFrameName) as MapFrame;
    var narrow_info = new NorthArrowInfo()
    {
      MapFrameName = mf.Name,
      NorthArrowStyleItem = naStyleItm
    };
    var arrowElm = (NorthArrow)ElementFactory.Instance.CreateMapSurroundElement(
      layout, center.ToMapPoint(), narrow_info) as NorthArrow;
    arrowElm.SetName("New North Arrow");
    arrowElm.SetHeight(1.75);
    arrowElm.SetX(7);
    arrowElm.SetY(6);
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also