I am trying to access the domain of a selected feature. I have seen examples for VB.NET and C#.NET, but I cannot access the domain of a specified field.
Dim findName As String = Nothing
Dim findValue As Integer = 21 'the domain value for AGRICULTURE
Dim fieldIndex As Integer = m_Feature.Fields.Field("my_field") 'this has a coded domain
'--Check for my_field
If fieldIndex <> -1 Then
Dim domain As IDomain = m_Feature.Field(fieldIndex).Domain
If domain.Type = esriDomainType.esriDTCodedValue Then
Dim cvDomain As ICodedValueDomain2 = TryCast(domain, ICodedValueDomain2)
For i = 0 To cvDomain.CodeCount - 1
If cvDomain.Value(i).Equals(findValue) Then
findName = cvDomain.Name(i)
Exit For
End If
Next i
End If
When debugging it hangs up on the line with domain.Type, and it shows that the value of Domain is Nothing. The documentation shows that IField.Domain should return the default domain as an IDomain object. I know the field has a domain, but I don't know if it is default and am unable to change it. Does anyone have any advice on how I should access the domain of a field (of a selected feature in my case)?