ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / FeatureLayer Class / SetFeatureDrawOrder Method / SetFeatureDrawOrder(String,SortOrderType) Method
The name of the field to use for drawing order. Cannot be null
The sort direction
Example

In This Topic
    SetFeatureDrawOrder(String,SortOrderType) Method
    In This Topic
    Set the layer feature drawing order. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Overloads Sub SetFeatureDrawOrder( _
       ByVal fieldName As String, _
       ByVal sortDirection As SortOrderType _
    ) 
    public void SetFeatureDrawOrder( 
       string fieldName,
       SortOrderType sortDirection
    )

    Parameters

    fieldName
    The name of the field to use for drawing order. Cannot be null
    sortDirection
    The sort direction
    Exceptions
    ExceptionDescription
    'field name' cannot be null or empty
    "Invalid drawing order inputs -check field name(s) exist and/or are the correct field type"
    Layer does not support feature drawing order
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    Any existing drawing order will be overwritten. Internally, GetCanSetFeatureDrawOrder(String,SortOrderType) is called to determine if the provided field can be used.
    Example
    Set Feature Drawing Order
    {
        //Within QueuedTask.Run()
        if (featureLayer.GetIsFeatureDrawOrderSupported())
        {
            //Provide the field name to use and the sort ordering
            //The field must exist on the layer. Check the field can be used first
            if (featureLayer.GetCanSetFeatureDrawOrder("Police_Precinct", SortOrderType.Ascending))
            {
                //Set the FDO to use the "Police_Precinct" field and ascending sort order
                featureLayer.SetFeatureDrawOrder("Police_Precinct", SortOrderType.Ascending);
            }
        }
    }
    Get the Current Feature Drawing Order
    {
        //Within QueuedTask.Run()
        if (featureLayer.GetIsFeatureDrawOrderSupported())
        {
            var cimFeatSortInfo = featureLayer.GetFeatureDrawOrder();
            var c = 0;
            System.Diagnostics.Debug.WriteLine("Feature Sort Info:");
            foreach (var fs_info in cimFeatSortInfo)
            {
                System.Diagnostics.Debug.WriteLine(
                  $"fs_info[{c++}] {fs_info.FieldName}: {fs_info.SortDirection.ToString()}");
            }
        }
    }
    Requirements

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

    ArcGIS Pro version: 3.6 or higher.
    See Also