ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Map Class / StandaloneTables Property
Example

In This Topic
    StandaloneTables Property (Map)
    In This Topic
    Gets all standalone tables of the map.
    Syntax
    public ReadOnlyObservableCollection<StandaloneTable> StandaloneTables {get;}
    Public ReadOnly Property StandaloneTables As ReadOnlyObservableCollection(Of StandaloneTable)
    Example
    Find a standalone table
    // these routines find a standalone table whether it is a child of the Map or a GroupLayer
    var tblFind = aMap.FindStandaloneTable("CIMPATH=map/address_audit.xml");
    
    IReadOnlyList<StandaloneTable> tables = aMap.FindStandaloneTables("addresses");
    
    // this method finds a standalone table as a child of the map only
    var table = aMap.StandaloneTables.FirstOrDefault(t => t.Name == "Addresses");
    Retrieve a table from its container
    var container = MapView.Active.Map;
    
    //the map standalone table collection
    var table = container.GetStandaloneTablesAsFlattenedList()
                            .FirstOrDefault(tbl => tbl.Name == "EarthquakeDamage");
    
    //or from a group layer
    var grp_layer = MapView.Active.Map.FindLayers("GroupLayer1").First() as GroupLayer;
    var table2 = grp_layer.FindStandaloneTables("EarthquakeDamage").First();
    //or         grp_layer.GetStandaloneTablesAsFlattenedList().First()
    //or         grp_layer.StandaloneTables.Where(...).First(), etc.
    
    //show the table in a table view 
    //use FrameworkApplication.Current.Dispatcher.BeginInvoke if not on the UI thread
    FrameworkApplication.Panes.OpenTablePane(table2);
    
    Move a Standalone table
    //get the first group layer that has at least one table
    var grp_layer = MapView.Active.Map.GetLayersAsFlattenedList()
      .OfType<GroupLayer>().First(g => g.StandaloneTables.Count > 0);
    var map = MapView.Active.Map;//assumes non-null
    QueuedTask.Run(() =>
    {
      //move the first table to the bottom of the container
      grp_layer.MoveStandaloneTable(grp_layer.StandaloneTables.First(), -1);
    
      //move the last table in the map standalone tables to a group
      //layer and place it at position 3. If 3 is invalid, the table
      //will be placed at the bottom of the target container
      //assumes the map has at least one standalone table...
      var table = map.StandaloneTables.Last();
      map.MoveStandaloneTable(table, grp_layer, 3);
    
      //move a table from a group layer to the map standalone tables
      //collection - assumes a table called 'Earthquakes' exists
      var table2 = grp_layer.FindStandaloneTables("Earthquakes").First();
      //move to the map container
      map.MoveStandaloneTable(table2, 0);//will be placed at the top
    });
    
    Remove a Standalone table
    //get the first group layer that has at least one table
    var grp_layer = MapView.Active.Map.GetLayersAsFlattenedList()
      .OfType<GroupLayer>().First(g => g.StandaloneTables.Count > 0);
    var map = MapView.Active.Map;//assumes non-null
    
    QueuedTask.Run(() =>
    {
      //get the tables from the map container
      var tables = map.GetStandaloneTablesAsFlattenedList();
      //delete the first...
      if (tables.Count() > 0)
      {
        map.RemoveStandaloneTable(tables.First());
        //or delete all of them
        map.RemoveStandaloneTables(tables);
      }
    
      //delete a table from a group layer
      //assumes it has at least one table...
      grp_layer.RemoveStandaloneTable(grp_layer.StandaloneTables.First());
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also