ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / Layout Class / SetName Method
String
Example

In This Topic
    SetName Method (Layout)
    In This Topic
    Sets the name of the layout. It is important that all layouts have a unique name so they can be easily referenced. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void SetName( 
       string name
    )
    Public Sub SetName( _
       ByVal name As String _
    ) 

    Parameters

    name
    String
    Exceptions
    ExceptionDescription
    This method must be called within the lambda passed to QueuedTask.Run.
    Example
    Layout_SetName
    //Change the name of a layout.
    
    //Perform on the worker thread
    await QueuedTask.Run(() =>
    {
      layout.SetName("New Name");
    });
    CreateLayout_WITH_WD_AND_HT
    //This example creates a new layout using a minimum set of parameters.
    
    //Added references
    using ArcGIS.Desktop.Layouts;                    
    using ArcGIS.Desktop.Framework.Threading.Tasks; 
    using ArcGIS.Desktop.Core;
    
    public class CreateLayoutEx1
    {
      async public static Task<Layout> CreateBasicLayout(double width, double height, LinearUnit units, string LayoutName)
      {
        Layout layout = null;
        await QueuedTask.Run(() =>
        {
          layout = LayoutFactory.Instance.CreateLayout(width, height, units);
          layout.SetName(LayoutName);
        });
    
        //Open the layout in a pane on the UI!
        await ProApp.Panes.CreateLayoutPaneAsync(layout);
    
        return layout;
      }
    }
    Create a new, basic layout and open it
    //Create a new, basic layout and open it.
    
    //Create layout with minimum set of parameters on the worker thread
    Layout lyt = await QueuedTask.Run(() =>
    {
      var newLayout = LayoutFactory.Instance.CreateLayout(8.5, 11, LinearUnit.Inches);
      newLayout.SetName("New 8.5x11 Layout");
      return newLayout;
    });
          
    //Open new layout on the GUI thread
    await ProApp.Panes.CreateLayoutPaneAsync(lyt);
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also