获取当前图层选择的feature
IFeatureLayer pFeatureLayer;
IFeatureSelection pFeatSel;
ISelectionSet pSelectionSet;
pFeatureLayer = pCurrentLayer as IFeatureLayer;
pFeatSel = (IFeatureSelection)pCurrentLayer;
pSelectionSet = pFeatSel.SelectionSet;
int lID;
IEnumIDs pEnumIDs;
pEnumIDs = pSelectionSet.IDs;
IFeature pFirstSelctedFeature;
IFeature pSetFeature;
IGeometry polygon;
lID = pEnumIDs.Next();
if (lID != -1)
{
pFirstSelctedFeature = pFeatureLayer.FeatureClass.GetFeature(lID);
}
其中 pCurrentLayer 为当前图层
IFeatureSelection pFeatSel;
ISelectionSet pSelectionSet;
pFeatureLayer = pCurrentLayer as IFeatureLayer;
pFeatSel = (IFeatureSelection)pCurrentLayer;
pSelectionSet = pFeatSel.SelectionSet;
int lID;
IEnumIDs pEnumIDs;
pEnumIDs = pSelectionSet.IDs;
IFeature pFirstSelctedFeature;
IFeature pSetFeature;
IGeometry polygon;
lID = pEnumIDs.Next();
if (lID != -1)
{
pFirstSelctedFeature = pFeatureLayer.FeatureClass.GetFeature(lID);
}
其中 pCurrentLayer 为当前图层