AnsweredAssumed Answered

ArcObjects C#: Return field domain code vs value

Question asked by jpacosta on Jan 12, 2015
Latest reply on Dec 6, 2015 by FGibson-esristaff

HI all,


I inherited a .NET class extension that provides a form so our techs can add/modify features and/or attributes. I had to add several fields to an existing layer which have to go on the form as a combo box. These new fields get populated based on the values that get returned from an overlay function. The overlay function is returning the domain code value instead of the code, so its returning the value "Aqua Hedionda Tributary" instead of the code "AHT". When the next function tries to populate the field with "Aqua Hedionda Tributary" it gets ignored as if it doesn't recognize the value, even though the dropdown list is populated with all of the code values from the field's domain.


These functions already exist, I'm just adding additional fields and layers for overlay and to be populated via the form.


Can anyone tell me what the issue is?

  1. Why in the overlay function do some features return the code and some features return the value?
  2. Why can't I pass the domain value to populate the comboBox.selectedValue.


Here's the code....

This call the overlay function

obj.Value(obj.Fields.FindField(Globals.SoCalWetlandType)) = Globals.overlayFC(obj, overlaySoCalWetland, "WetType")


This is the overlay function

 Public Function overlayFC(ByRef obj As IObject, ByRef layerName As String, ByRef fieldname As String) As String
        Dim pWorkspace As IWorkspace
        Dim pObjectClass As IObjectClass
        Dim pdataset As IDataset
        Dim pFC As IFeatureClass
        Dim pFeatCursor As IFeatureCursor
        Dim pFeat As IFeature
        Dim result As String = Nothing
        Dim i As Int32 = 0

        pObjectClass = obj.Class
        pdataset = CType(pObjectClass, IDataset)
        pWorkspace = pdataset.Workspace
        pFC = OpenFC(pWorkspace, layerName)
        Dim pSP As ISpatialFilter
        pSP = New SpatialFilter
        pSP.Geometry = CType(obj.Value(obj.Fields.FindField("Shape")), IGeometry5)
        pSP.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
        pSP.GeometryField = pFC.ShapeFieldName
        pFeatCursor = pFC.Search(pSP, True)
        pFeat = pFeatCursor.NextFeature()
        Do Until pFeat Is Nothing
            'If i > 0 Then result = result + ", "
            result = result + pFeat.Value(pFeat.Fields.FindField(fieldname)).ToString
            'i = i + 1
            pFeat = pFeatCursor.NextFeature()
        Return result






This is the form where the cbo boxes get populated with the domains and where the values from the overlay function get passed as the selected value.

Public Property frmTarget() As IObject

        'This property is a reference to the feature being created or edited. When the feature is selected then 
        'this  property gets updated by the parent class extension. When this happens the data entry fields are updated
        'by this section
            Return _object
        End Get
        Set(ByVal value As ESRI.ArcGIS.Geodatabase.IObject)
            _object = value
            If Not _object Is Nothing Then
                If Not m_bCombosFilled Then
                    'Dim RecName = "AHCT"
                    'Dim SoCalType = "FLUV"
                    '1.5.15 JPA - populated by overlay
                    m_dctDomainValueHolder = Globals.getDomainArray(_object, Globals.SoCalWetlandType)
                    m_bsSoCalWetlandType.DataSource = m_dctDomainValueHolder
                    With cboSoCalWetlandType
                        .DisplayMember = "Key"
                        .ValueMember = "Value"
                        .DataSource = m_bsSoCalWetlandType
                    End With
                    'cboReceiveWaterBuffer.SelectedIndex = -1
                    'cboSoCalWetlandType.SelectedValue = SoCalType
                    cboSoCalWetlandType.SelectedValue = _object.Value(_object.Fields.FindField(Globals.SoCalWetlandType)).ToString

                End if    
            End If
        End Set
    End Property