主要实现点击查询并闪烁显示,并把查询要素的信息通过DataGridView显示出来,主要用到的接口:

IIdentity、IArray、IIdentifyObj、IFeatureObj、IRowIdentifyObject、IFeature

代码:

Identify
IGroupLayer pGroupLayer = new GroupLayerClass();
for (int i = 0; i < axMapControl1.Map.LayerCount; i++)
{
pGroupLayer.Add(axMapControl1.Map.get_Layer(i));
}
IIdentify pIdentify
= pGroupLayer as IIdentify;
IPoint point
= new PointClass();
point.PutCoords(e.mapX, e.mapY);


IArray pID
= pIdentify.Identify(point);
IFeatureIdentifyObj pFeatIdentifyObj;
IIdentifyObj pIdentifyObj;

pFeatIdentifyObj
= pID.get_Element(0) as IFeatureIdentifyObj;
pIdentifyObj
= pFeatIdentifyObj as IIdentifyObj;
pIdentifyObj.Flash(axMapControl1.ActiveView.ScreenDisplay);
IRowIdentifyObject pRowObject
= pFeatIdentifyObj as IRowIdentifyObject;
IFeature pFeature
= pRowObject.Row as IFeature;

DataTable pDatatable
= new DataTable();
for (int i = 0; i < pFeature.Fields.FieldCount; i++) //加载每一列字段的名字
{
pDatatable.Columns.Add(pFeature.Fields.get_Field(i).Name);
}
DataRow pDataRow
= pDatatable.NewRow(); //加载查询要素的信息
for (int i = 0; i < pFeature.Fields.FieldCount; i++)
{
pDataRow[i]
= pFeature.get_Value(i);
}
pDatatable.Rows.Add(pDataRow);
//Iden是另外设置的属性窗口
DataGridView pDataGridView = Iden.Get_DataGridView;
pDataGridView.DataSource
= pDatatable;
Iden.Show();

相关文章:

  • 2021-11-28
  • 2021-10-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-17
  • 2021-11-21
  • 2021-08-13
  • 2022-01-30
  • 2021-11-28
  • 2021-07-06
  • 2021-06-24
相关资源
相似解决方案