ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Core.Data Namespace / CodedValueDomain Class
Members Example

In This Topic
    CodedValueDomain Class
    In This Topic
    Represents the information about the valid coded values belonging to this coded value domain.
    Syntax
    public sealed class CodedValueDomain : Domain, System.IDisposable  
    Public NotInheritable Class CodedValueDomain 
       Inherits Domain
       Implements System.IDisposable 
    Remarks
    A CodedValueDomain maintains the information about the valid coded values belonging to this coded value domain. Domains may be assigned to a field at the table level or if the table has subtypes, they would be assigned at the subtype level. A domain indicates the valid values for a field, and will indicate during validation if the field value is outside of this valid list.
    Example
    Get domain string from a field
    public string GetDomainStringFromField(Row row, Field field)
    {
      // Get the table and table definition from the Row
      using (Table table = row.GetTable())
      using (TableDefinition tableDefinition = table.GetDefinition())
      {
        // Get name of subtype field
        string subtypeFieldName = tableDefinition.GetSubtypeField();
    
        // Get subtype, if any
        Subtype subtype = null;
    
        if (subtypeFieldName.Length != 0)
        {
          // Get value of subtype field for this row
          object varSubtypeCode = row[subtypeFieldName];
          long subtypeCode = (long)varSubtypeCode;
    
          // Get subtype for this row
          subtype = tableDefinition.GetSubtypes().First(x => x.GetCode() == subtypeCode);
        }
    
        // Get the coded value domain for this field
        CodedValueDomain domain = field.GetDomain(subtype) as CodedValueDomain;
    
        // Return the text string for this field
        if (domain != null)
        {
          return domain.GetName(row[field.Name]);
        }
        else
        {
          return row[field.Name].ToString();
        }
      }
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.CoreObjectsBase
          ArcGIS.Core.Data.Domain
             ArcGIS.Core.Data.CodedValueDomain

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also