ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / TableView Class / GetSelectedRowIndexes Method
Example

In This Topic
    GetSelectedRowIndexes Method (TableView)
    In This Topic
    Gets the indexes of all the selected rows. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function GetSelectedRowIndexes() As IReadOnlyList(Of Long)
    public IReadOnlyList<long> GetSelectedRowIndexes()

    Return Value

    A read-only list of row indexes.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Get selected rows or row indexes
    {
      // Note: Needs QueuedTask to run
      {
        // get the set of selected objectIDs 
        var selOids = tableView.GetSelectedObjectIds();
        // get the set of selected row indexes
        var selRows = tableView.GetSelectedRowIndexes();
      }
    }
    Change selected rows
    {
      // Note: Needs QueuedTask to run
      {
        // set of selected OIDS
        var newoids = new List<long>();
        newoids.AddRange([10, 15, 17]);
        tableView.Select(newoids, true);
    
        // add to set of selected row indexes
        var selRows = tableView.GetSelectedRowIndexes();
        var newRows = new List<long>(selRows);
        newRows.AddRange([21, 35]);
        tableView.Select(newRows, false);
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.1 or higher.
    See Also