分类: WINDOWS
2011-08-30 17:18:48
public IFeature getSelLayerFeature(int nIndexLayer)
{
IFeature fea = null;
IFeatureLayer pFeaLayer;
pFeaLayer = this.m_axMapControl.Map.get_Layer(nIndexLayer) as IFeatureLayer;
IFeatureSelection pFeatSel = (IFeatureSelection)pFeaLayer;
ISelectionSet pSelectionSet = pFeatSel.SelectionSet;
if (pSelectionSet.Count == 0)
{
Console.WriteLine("在 '" + pFeaLayer.Name + "' 图层没有要素被选中!");
return null;
}
int id = -1;
IEnumIDs ids = pSelectionSet.IDs;
id = ids.Next();
// Console.WriteLine(id.ToString());
if(id!=-1)
{
fea = pFeaLayer.FeatureClass.GetFeature(id);
}
return fea;
}
本文来自: