C#加ArgisEngine二次开发点要素的点击事件

图片说明

如上图,怎么点击里面的点元素,弹出信息框。

地图上的要素一般都是框选的吧,你添加框选的toolbar,实现控件上的on_mouse_up事件

         private void axMapControl1_OnMouseUp(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseUpEvent e)
        {
            try
            {
                IMap pMap = axMapControl1.Map;
                ISelection pSelection = pMap.FeatureSelection;
                IEnumFeatureSetup pEnumFeatureSetup = (IEnumFeatureSetup)pSelection;
                pEnumFeatureSetup.AllFields = true;
                IEnumFeature pEnumFeature = (IEnumFeature)pEnumFeatureSetup;
                pEnumFeature.Reset();
                IFeature pFeature = pEnumFeature.Next();
                while (pFeature != null)
                {
                    string name = pFeature.get_Value(3).ToString();
                    string id = pFeature.get_Value(2).ToString();
                    MessageBox.Show("编号         :"+id+Environment.NewLine+"名称         :"+name,"要素属性");
                    pFeature = pEnumFeature.Next();
                }
                //if (pFeature == null)
                //{
                //    MessageBox.Show("请选择要素!", "错误");

                //}

            }
            catch
            {


            }
        }