所选中的要素,赋值给一个定义好的变量pCurFea
问题提出:ARCengine中,我用arcgis的选择工具实现了选择功能。代码如下:
private void 选择要素ToolStripMenuItem_Click(object sender, EventArgs e)
{
ESRI.ArcGIS.Controls.ControlsSelectFeaturesTool select = new ESRI.ArcGIS.Controls.ControlsSelectFeaturesTool();
select.OnCreate(axMapControl1.Object);
axMapControl1.CurrentTool = select as ESRI.ArcGIS.SystemUI.ITool;
}
现在,我想要编写代码使如上功能所选中的要素,赋值给一个定义好的变量pCurFea。代码该怎么写?pCurFea=???
本网编辑推荐答案:
推荐答案1:Public Sub LoopThruSelection()
Dim pDoc As IMxDocument
Dim pMap As IMap
Dim pEnumFeat As IEnumFeature
Dim pFeat As IFeature
Set pDoc = ThisDocument
Set pMap = pDoc.FocusMap
Set pEnumFeat = pMap.FeatureSelection
Set pFeat = pEnumFeat.Next
Do While (Not pFeat Is Nothing)
Debug.Print pFeat.Value(pFeat.Fields.FindField("Name"))
Set pFeat = pEnumFeat.Next
Loop
End Sub
希望你能看懂 多去论坛看看