ArcGIS Explorer Component Help |
CodedValueDomain..::.GetCodedValuePairs Method |
CodedValueDomain Class Example See Also |
Gets a SortedList of the all the value/name pairs which make up the contents of the domain.
Namespace:
ESRI.ArcGISExplorer.DataAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public SortedList<Object, string> GetCodedValuePairs() |
Visual Basic (Declaration) |
---|
Public Function GetCodedValuePairs As SortedList(Of Object, String) |
Return Value
A SortedList object consisting of value/name pairs, representing the contents of the Domain.Remarks
Care needs to be taken not to confuse the contents of the SortedList as it stores the domain
contents as a list of Keys and a list of Values. The Keys list stores all the domain values, whereas
the Values list stores all the descriptive names.
Examples
The code below returns the Domain associated with a Column in a geodatabase feature class using
the GetDomain method then prints out the all the value/name pairs using the GetCodedValuePairs method.
CopyC#
Table tanks = Table.OpenFileGeodatabaseTable(@"C:\Data\Montgomery.gdb", "tanks"); //check that the "AncillaryRole" column of the "tanks" feature class has a Domain and //that the Table is not subtyped (i.e there can only be a single Domain defined for this column). if ((tanks.Columns["AncillaryRole"].HasDomain) && (tanks.IsSubtyped == false)) { //return the Domain Domain domain = tanks.Columns["AncillaryRole"].GetDomain(); //check the Domain type if (domain.Type == DomainType.CodedValue) { CodedValueDomain cvDom = domain as CodedValueDomain; //Print the Domain name System.Diagnostics.Debug.Print(cvDom.Name); //Prints "AncillaryRoleDomain" //Print out all the contents of the domain for (int i = 0; i < cvDom.GetCodedValuePairs().Count -1; i++) { string domainInfo = string.Format("Value: {0}, Name: {1}",cvDom.GetCodedValuePairs().Keys[i].ToString(), cvDom.GetCodedValuePairs().Values[i].ToString()); System.Diagnostics.Debug.Print(domainInfo); } } }
CopyVB.NET
Dim tanks As Table = Table.OpenFileGeodatabaseTable("C:\Data\Montgomery.gdb", "tanks") 'check that the "AncillaryRole" column of the "tanks" feature class has a Domain and 'that the Table is not subtyped (i.e there can only be a single Domain defined for this column). If ((tanks.Columns.Item("AncillaryRole").HasDomain) And (tanks.IsSubtyped = False)) Then 'return the Domain Dim domain As Domain = tanks.Columns.Item("AncillaryRole").GetDomain() 'check the Domain type If (domain.Type = DomainType.CodedValue) Then Dim cvDom As CodedValueDomain = DirectCast(domain, CodedValueDomain) 'Print the Domain name System.Diagnostics.Debug.Print(cvDom.Name) 'Prints "AncillaryRoleDomain" 'Print out all the contents of the domain For i As Integer = 0 To cvDom.GetCodedValuePairs().Count - 1 Dim domainInfo As String = String.Format("Value: {0}, Name: {1}", cvDom.GetCodedValuePairs().Keys.Item(i).ToString(), _ cvDom.GetCodedValuePairs().Values.Item(i).ToString()) System.Diagnostics.Debug.Print(domainInfo) Next End If End If