2

I've done this:

while (feature != null)
            {
                if ((feature.get_Value(feature.Fields.FindField("NAME")) != null) && (feature.get_Value(feature.Fields.FindField("NAME")).ToString() != " "))
                {
                    itemList.Add(feature.get_Value(feature.Fields.FindField("NAME")).ToString());
                }
                feature = featureCursor.NextFeature();
            }

Now I have a listBox with fields values. How can I get a feature back by its name?

The idea was:

  1. create a list with objects names,
  2. find feature on map, clicking by its name on list.

Features (objects) represent as points.

2

The best option is to use a query to get back the corresponding feature:

IQueryFilter queryFilter = new QueryFilterClass();
queryFilter.WhereClause = "NAME = '<featureName>'";

using (ComReleaser comReleaser = new ComReleaser())
{
  ICursor cursor = table.Search(queryFilter, true);
  comReleaser.ManageLifetime(cursor);
  IRow row = null;
  while ((row = cursor.NextRow()) != null)
  {
    String name = row.get_Value(nameIndex);
    IFeature featureBack = row as IFeature;
  }
}
4

IQueryFilter is the best option for your problem.You can put your name value in the whereclause of the queryfilter and thereby you can get the desired feature.

ESRI.ArcGIS.Geodatabase.IQueryFilter queryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
queryFilter.WhereClause = "NAME LIKE 'LIGHT_POLE';     
ESRI.ArcGIS.Geodatabase.ICursor cursor = featureLayer.Search(queryFilter, false);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.