ARCGIS插件开发(C#)

搜索全部Name=输入值的feature,可以通过如下方式实现

var data = new List();
            IEnumLayer enumLayer = Map.get_Layers(null, false);//所有layer
            enumLayer.Reset();
            ILayer layer = null;
            while ((layer = enumLayer.Next()) != null)
            {
                ///搜索条件
                var qfc = new QueryFilterClass();
                qfc.WhereClause = string.Format("Name = '{0}'", tboxName.Text);
                var featureLayer = layer as IFeatureLayer;
                if(featureLayer != null)
                {
                    IFeatureCursor cursor = featureLayer.Search(qfc, false);
                    //按照查询条件选中
                    var pFeatureSelection = featureLayer as IFeatureSelection;
                    pFeatureSelection.SelectFeatures(qfc, esriSelectionResultEnum.esriSelectionResultNew, false);//选中
                    
                    //获取全部feature
                    IFeature feature = cursor.NextFeature();
                    while(feature != null)
                    {
                        data.Add(feature);
                        feature = cursor.NextFeature();
                    }
                }
            }

可以通过feature.Fields.FieldCount获取字段总数,to难过过feature.get_value(index).获取第index个字段的值.

你可能感兴趣的:(C#,GIS,ArcGis,C#,插件,查询)