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?
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() Loop Return result Function
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 Get 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
I'll have to take a look at this one when I get to the office tomorrow, but this is what I'm thinking right now. Let's say that you had a domain with the following information.
Code | Value |
No | 0 |
Yes | 1 |
Maybe | 2 |
Let's call this domain "UserResponse" and say that the type of the field that stores the value is Integer, but we're displaying strings for the codes. I would expect that if I were to use a cursor to grab the values from the database that it would return the actual value of the field (i.e. the integer values of 0, 1, or 2) instead of the coded value string.
I know that if we were to edit these values in ArcMap that we could pick the coded value strings from the dropdown and the software would convert them to their actual values, but I'm not sure if a cursor would natively do the same thing.