ArcGIS Pro SDK - Select feature from FeatureLayer

3005
2
Jump to solution
10-31-2019 09:10 AM
OscarDiago_Alonso
New Contributor III

Hi!

I want to select a feature from a FeatureLayer using a query and I can't find any example of it.

The closest code snippet I have found uses somekind of selection by intersection, but that is not going to work for me:

 Dim qf As QueryFilter = New QueryFilter()

qf.WhereClause = "Filed1= " & myVariable

Using rowCursor As RowCursor = fEdif.Search(qf)
    While rowCursor.MoveNext()
         Dim feature1 As Feature = TryCast(rowCursor.Current, Feature)
         Dim geo As ArcGIS.Core.Geometry.Geometry = feature1.GetShape()

          MapView.Active.SelectFeatures(geo)
                                       
     End While
End Using‍‍‍‍‍‍‍‍‍‍‍‍‍

That way the building I want is selected, but also the ones that are attached to it.

So, how can I just select the feature that is returned by the search?

The FeatureLayer has a method called SetSelection, but I can't find any example of how to use it.

Thanks for any help provided!!

0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi Oscar,

You do not need any code snippet. Just use Select method from FeatureLayer. Like that:

featLayer.Select(qf); // your query filter

View solution in original post

2 Replies
GKmieliauskas
Esri Regular Contributor

Hi Oscar,

You do not need any code snippet. Just use Select method from FeatureLayer. Like that:

featLayer.Select(qf); // your query filter

OscarDiago_Alonso
New Contributor III

Thanks!

I got the wrong idea that that method only worked with QuerySpatialFilter.

0 Kudos