<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ArcObject for reading a record value for a particular field in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcobject-for-reading-a-record-value-for-a/m-p/292999#M7613</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am writing a tool to read and compare two values (from two separate records) in a particular field. I cant seem to determine what ArcObject I need in order to read the value within the field. I will be reading a feature class within a gdb, not editing records... this tool is simply for record comparisons. Any help is greatly appriciated.. thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Aug 2011 18:41:20 GMT</pubDate>
    <dc:creator>JulietMora</dc:creator>
    <dc:date>2011-08-16T18:41:20Z</dc:date>
    <item>
      <title>ArcObject for reading a record value for a particular field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcobject-for-reading-a-record-value-for-a/m-p/292999#M7613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am writing a tool to read and compare two values (from two separate records) in a particular field. I cant seem to determine what ArcObject I need in order to read the value within the field. I will be reading a feature class within a gdb, not editing records... this tool is simply for record comparisons. Any help is greatly appriciated.. thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Aug 2011 18:41:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/arcobject-for-reading-a-record-value-for-a/m-p/292999#M7613</guid>
      <dc:creator>JulietMora</dc:creator>
      <dc:date>2011-08-16T18:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: ArcObject for reading a record value for a particular field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcobject-for-reading-a-record-value-for-a/m-p/293000#M7614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Juliet,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is a very rudimentary way of comparing the value of one field in two selected features.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You could call this method from a button click in a C# Add-In. If you are working in VBA or VB.NET then it will be a little different, but the interfaces used will be the same. Of course, replace the "YOUR_FIELDNAME" in the code with the actual field name.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
public void PerformTest()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Get the selection in TOC.
&amp;nbsp;&amp;nbsp;&amp;nbsp; object item = ArcMap.Document.SelectedItem;

&amp;nbsp;&amp;nbsp;&amp;nbsp; // Make sure it is a feature layer
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (item is IFeatureLayer)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IFeatureLayer featureLayer = item as IFeatureLayer;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IFeatureSelection featureSelection = featureLayer as IFeatureSelection;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISelectionSet selectionSet = featureSelection.SelectionSet;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Make sure exactly 2 features are selected
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (selectionSet.Count == 2)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Get a cursor
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ICursor cursor = null;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selectionSet.Search(null, true, out cursor);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Get the index of the subject field
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int fieldIdx = featureLayer.FeatureClass.FindField("YOUR_FIELDNAME");

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Typically you would cycle the rows of the cursor in a loop, but since
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // we know we have exactly 2 rows to compare, just grab them.

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set current row to first selected feature and get the field's value
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IRow row = cursor.NextRow();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string value1 = row.get_Value(fieldIdx).ToString();

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set current row to second selected feature and get the field's value
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = cursor.NextRow();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string value2 = row.get_Value(fieldIdx).ToString();

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Display the two values
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show("Feature 1: " + value1 +
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "\nFeature 2: " + value2);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show("Please select exactly 2 features.");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; else
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show("Please select a feature layer.");
&amp;nbsp;&amp;nbsp;&amp;nbsp; }


}
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:05:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/arcobject-for-reading-a-record-value-for-a/m-p/293000#M7614</guid>
      <dc:creator>JeffreyHamblin</dc:creator>
      <dc:date>2021-12-11T14:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: ArcObject for reading a record value for a particular field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcobject-for-reading-a-record-value-for-a/m-p/293001#M7615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hai Jeff, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Am also in the similar process. Can you please give me some sample to select single and group of features from a specified layer on mouse click at runtime. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In this above mentioned code all working fine, But the selectionset count is 0. How can i select feature(Probably polygon) from layer? I need to select only one feature at a time. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you have any sample regarding this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2011 09:27:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/arcobject-for-reading-a-record-value-for-a/m-p/293001#M7615</guid>
      <dc:creator>Ariharan</dc:creator>
      <dc:date>2011-11-09T09:27:57Z</dc:date>
    </item>
  </channel>
</rss>

