ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / GridOptionsEnvironment Class / HasGridOptions Method
Example

In This Topic
    HasGridOptions Method (GridOptionsEnvironment)
    In This Topic
    Gets whether a map currently has any grid options
    Syntax
    Public Function HasGridOptions( _
       ByVal map As Map _
    ) As Boolean
    public bool HasGridOptions( 
       Map map
    )

    Parameters

    map

    Return Value

    Example
    Get the Grid Options for a Map
    {
        QueuedTask.Run(() =>
        {
            //Does the 'map' currently have any options?
            var hasOptions = GridOptionsEnvironment.Instance.HasGridOptions(map);
    
            //If grid options have not been set for the map, then default grid options are added
            //for the map otherwise the existing gridoptions are returned.
            //NOTE: Grid options are returned by value meaning a copy is always returned. Any changes made to the
            //grid options need to be -set- back on the map using SetGridOptions for the changes to persist.
            var gridOptions = GridOptionsEnvironment.Instance.GetGridOptions(
                                       MapView.Active.Map);
    
            //Only return grid options if grid options have previously been set:
            var gridOptions2 = GridOptionsEnvironment.Instance.GetGridOptions(
                                       MapView.Active.Map, false);
        });
    }
    Reset the Grid Options for a Map back to Defaults
    {
        QueuedTask.Run(() =>
        {
            if (GridOptionsEnvironment.Instance.HasGridOptions(map))
            {
                //set back to defaults - will overwrite existing
                GridOptionsEnvironment.Instance.SetGridOptions(map, 
                    GridOptionsEnvironment.Instance.DefaultGridOptions);
            }
        });
    }
    Remove the Grid Options from a Map
    {
        QueuedTask.Run(() =>
        {
            if (GridOptionsEnvironment.Instance.HasGridOptions(map))
                GridOptionsEnvironment.Instance.RemoveGridOptions(map);
        });
    }
    Requirements

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

    ArcGIS Pro version: 3.7 or higher.
    See Also