<?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 Re: Get field attribute problem in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605548#M16216</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;haha, it's not really working, because it returns the values of the first row, in the attribute table.&amp;nbsp; I just want the values of the selected feature.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Jun 2012 13:55:09 GMT</pubDate>
    <dc:creator>DaveCouture</dc:creator>
    <dc:date>2012-06-20T13:55:09Z</dc:date>
    <item>
      <title>Get field attribute problem</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605542#M16210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;After selecting a feature through a query, I'd like a message box to pop up with 2 field values. This is what I have (in red):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; Public Sub SelectMapFeaturesByAttributeQuery(ByVal activeView As IActiveView, ByVal featureLayer As IFeatureLayer, ByVal whereClause As System.String)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If activeView Is Nothing OrElse featureLayer Is Nothing OrElse whereClause Is Nothing Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim featureSelection As IFeatureSelection = TryCast(featureLayer, IFeatureSelection) ' Dynamic Cast

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Set up the query
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim queryFilter As IQueryFilter = New QueryFilterClass
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryFilter.WhereClause = whereClause

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Invalidate only the selection cache. Flag the original selection
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Perform the selection
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; featureSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultNew, False)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' If PID found, Flag the new selection
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If featureSelection.SelectionSet.Count() = 0 Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox("Can't find the PID")
&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; activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Zoom to selected feature, if checkmarked
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If CheckBox1.CheckState = 1 Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pUID As New UID
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pUID.Value = "esriArcMapUI.ZoomToSelectedCommand"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; My.ArcMap.Application.Document.CommandBars.Find(pUID).Execute()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Display Owner's Name and PAN in message box
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim cursor As IFeatureCursor
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim feature As IFeature
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim patspan As String
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim taxname As String

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; featureSelection.SelectionSet.Search(Nothing, False, cursor)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feature = cursor.NextFeature
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; patspan = feature.Fields.FindField("patspan")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; taxname = feature.Fields.FindField("taxname")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do Until feature Is Nothing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox("PAN: " + feature.Value(patspan) + vbNewLine + "Owner's Name: " + feature.Value(taxname))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feature = cursor.NextFeature
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop&amp;nbsp;&amp;nbsp; 
 End Sub

End Class&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:41:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605542#M16210</guid>
      <dc:creator>DaveCouture</dc:creator>
      <dc:date>2021-12-12T16:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Get field attribute problem</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605543#M16211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The variables 'patspan' and 'taxname' need to be declared as Integer.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 13:17:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605543#M16211</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2012-06-20T13:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: Get field attribute problem</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605544#M16212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Bruce, that fixed one problem. Now I get the MessageBox, but I get no values. I believe the problem is with the cursor, because it says the cursor is use without being assigned a value, in the following statement:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;featureSelection.SelectionSet.Search(Nothing, False, cursor)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 13:26:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605544#M16212</guid>
      <dc:creator>DaveCouture</dc:creator>
      <dc:date>2012-06-20T13:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: Get field attribute problem</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605545#M16213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try changing 'cursor' from IFeatureCursor to ICursor.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 13:39:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605545#M16213</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2012-06-20T13:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Get field attribute problem</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605546#M16214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I got it to work.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I changed this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;featureSelection.SelectionSet.Search(Nothing, False, cursor)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;with this: &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;cursor = featureLayer.Search(Nothing, False)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But, I'm getting the values of the first row, not the selected feature.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 13:45:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605546#M16214</guid>
      <dc:creator>DaveCouture</dc:creator>
      <dc:date>2012-06-20T13:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: Get field attribute problem</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605547#M16215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Whatever works. I'm still learning too.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 13:49:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605547#M16215</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2012-06-20T13:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: Get field attribute problem</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605548#M16216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;haha, it's not really working, because it returns the values of the first row, in the attribute table.&amp;nbsp; I just want the values of the selected feature.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 13:55:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605548#M16216</guid>
      <dc:creator>DaveCouture</dc:creator>
      <dc:date>2012-06-20T13:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Get field attribute problem</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605549#M16217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You should put your query filter into the Search&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;cursor = featureLayer.Search(queryFilter, False)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 14:40:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605549#M16217</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2012-06-20T14:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: Get field attribute problem</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605550#M16218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gosh, it seems so obvious now..lol&amp;nbsp; Thanks a bunch, Ken!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 14:46:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605550#M16218</guid>
      <dc:creator>DaveCouture</dc:creator>
      <dc:date>2012-06-20T14:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: Get field attribute problem</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605551#M16219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;haha, it's not really working, because it returns the values of the first row, in the attribute table.&amp;nbsp; I just want the values of the selected feature.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In this line of code that 'works' you are searching the entire FeatureClass not the SelectionSet&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor = featureLayer.Search(Nothing, False)

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think what you are missing in your previous code is explicitly initializing the ICursor.&amp;nbsp; I am not a VB guy in C# it would be&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; ICursor cursor = null;
&amp;nbsp;&amp;nbsp;&amp;nbsp; featureSelection.SelectionSet.Search(null, false, cursor)

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something like this in VB&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim cursor as ICursor
&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor = Nothing
&amp;nbsp;&amp;nbsp;&amp;nbsp; featureSelection.SelectionSet.Search(Nothing, False, cursor)

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:57:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605551#M16219</guid>
      <dc:creator>JoeHershman</dc:creator>
      <dc:date>2021-12-12T01:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: Get field attribute problem</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605552#M16220</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Joe, thanks for your reply, but I had already tried that without success.&amp;nbsp; Instead of trying to get the selected feature in the cursor, it's just easier to re-perform the selection query, from the cursor; as Ken pointed out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;cursor = featureLayer.Search(queryFilter, False)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 14:56:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-field-attribute-problem/m-p/605552#M16220</guid>
      <dc:creator>DaveCouture</dc:creator>
      <dc:date>2012-06-20T14:56:11Z</dc:date>
    </item>
  </channel>
</rss>

