ArcGIS Explorer Component Help |
RowValueCollection..::.Item Property (Int32) |
RowValueCollection Class Example See Also |
Gets a value from the RowValueCollection given the specified column index position.
Namespace:
ESRI.ArcGISExplorer.DataAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public Object this[ int index ] { get; } |
Visual Basic (Declaration) |
---|
Public ReadOnly Default Property Item ( _ index As Integer _ ) As Object |
Parameters
- index
- Type: System..::.Int32
The index position of the Column in the Table.
Field Value
An Object which is the value stored in the RowValueCollection at the specified index.Examples
The code below provides three examples of how to access data stored in a Row using the RowValueCollection.
Example 2 accesses values stored in the RowValueCollection by index position.
CopyC#
//Open Montgomery file geodatabase Geodatabase gdb = new Geodatabase(@"C:\Data\Montgomery.gdb"); //Open the parcels featureclass Table parcels = gdb.OpenTable("parcels"); //Get a single parcel Row row = parcels.GetRow(3704); //Get the RowValueCollection for this Row RowValueCollection values = row.Values; //Example 1 - iterate over the RowValueCollection using a 'for each' loop printing out the column values. foreach (object val in values) { System.Diagnostics.Debug.Print(val.ToString()); } //Example 2- iterate over the RowValueCollection using a 'for' loop printing out the column names //and their associated values. The coded value will be printed for any columns which have an //associated coded value domain defined. for (int i = 0; i < values.ColumnCount; i++) { //Get the name of the column string columnName = values.Columns[i].Name; string rowValue = string.Empty; if ((values.Columns[i].HasDomain) && (values.Columns[i].GetDomain().Type == DomainType.CodedValue)) { //Get the coded value if a coded value domain is defined against this column rowValue = values.GetCodedName(i); } else { //Get the actual value stored in the table rowValue = values[i].ToString(); } //Print the column name and the value for every column in this Row System.Diagnostics.Debug.Print(string.Format("Column Name: {0}, Row Value: {1}", columnName, rowValue)); } //Example 3 - Get values for individual columns //Get the unique id value maintained by the geodatabase. int uniqueID = (int)values[parcels.Columns.ObjectIDColumnName]; System.Diagnostics.Debug.Print(uniqueID.ToString()); //Get the actual value stored in the table for the 'Zoning_S' column string zoningValue = (string)values["ZONING_S"]; System.Diagnostics.Debug.Print(zoningValue); //Prints "R" //Get the coded value stored in the domain associated with the 'Zoning_S' column string zoningCodedDomainValue = (string)values.GetCodedName("ZONING_S"); System.Diagnostics.Debug.Print(zoningCodedDomainValue); //Prints "Residential"
CopyVB.NET
'Open Montgomery file geodatabase Dim gdb As Geodatabase = New Geodatabase("C:\Data\Montgomery.gdb") 'Open the parcels featureclass Dim parcels As Table = gdb.OpenTable("parcels") 'Get a single parcel Dim r As Row = parcels.GetRow(3704) 'Get the RowValueCollection for this Row Dim values As RowValueCollection = r.Values 'Example 1 - iterate over the RowValueCollection using a 'for each' loop printing out the column values. For Each val As Object In values System.Diagnostics.Debug.Print(val.ToString()) Next 'Example 2 - iterate over the RowValueCollection using a 'for' loop printing out the column names 'and their associated values. The coded value will be printed for any columns which have an 'associated coded value domain defined. For i As Integer = 0 To values.ColumnCount - 1 'Get the name of the column Dim columnName As String = values.Columns.Item(i).Name Dim rowValue As String = String.Empty If ((values.Columns.Item(i).HasDomain) And (values.Columns.Item(i).GetDomain().Type = DomainType.CodedValue)) Then 'Get the coded value if a coded value domain is defined against this column rowValue = values.GetCodedName(i) Else 'Get the actual value stored in the table rowValue = values.Item(i).ToString() End If 'Print the column name and the value for every column in this Row System.Diagnostics.Debug.Print(String.Format("Column Name: {0}, Row Value: {1}", columnName, rowValue)) Next 'Example 3 - Get values for individual columns 'Get the unique id value maintained by the geodatabase. Dim uniqueID As Integer = DirectCast(values.Item(parcels.Columns.ObjectIDColumnName), Integer) System.Diagnostics.Debug.Print(uniqueID.ToString()) 'Get the actual value stored in the table for the 'Zoning_S' column Dim zoningValue As String = DirectCast(values.Item("ZONING_S"), String) System.Diagnostics.Debug.Print(zoningValue) 'Prints "R" 'Get the coded value stored in the domain associated with the 'Zoning_S' column Dim zoningCodedDomainValue As String = DirectCast(values.GetCodedName("ZONING_S"), String) System.Diagnostics.Debug.Print(zoningCodedDomainValue) 'Prints "Residential"