日期:2014-05-17 浏览次数:20834 次
public partial class AttributeQueryForm : Form
{
//地图数据
private AxMapControl mMapControl;
//选中图层
private IFeatureLayer mFeatureLayer;
public AttributeQueryForm(AxMapControl mapControl)
{
InitializeComponent();
this.mMapControl = mapControl;
}
private void AttributeQueryForm_Load(object sender, EventArgs e)
{
//MapControl中没有图层时返回
if (this.mMapControl.LayerCount <= 0)
return;
//获取MapControl中的全部图层名称,并加入ComboBox
//图层
ILayer pLayer;
//图层名称
string strLayerName;
for (int i = 0; i < this.mMapControl.LayerCount; i++)
{
pLayer = this.mMapControl.get_Layer(i);
strLayerName = pLayer.Name;
//图层名称加入cboLayer
this.cboLayer.Items.Add(strLayerName);
}
//默认显示第一个选项
this.cboLayer.SelectedIndex = 0;
}
private void cboLayer_SelectedIndexChanged(object sender, EventArgs e)
{
//获取cboLayer中选中的图层
mFeatureLayer = mMapControl.get_Layer(cboLayer.SelectedIndex) as IFeatureLayer;
IFeatureClass pFeatureClass = mFeatureLayer.FeatureClass;
//字段名称
string strFldName;