AE中Identify查询工具的实现

 主要实现点击查询并闪烁显示,并把查询要素的信息通过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();

posted @ 2011-04-01 16:52  师士  阅读(1930)  评论(0编辑  收藏  举报