1、先在主窗體中添加一個“詳細資訊按鈕”,輕按兩下這個按鈕添加如下事件:

這個pMouseOperate是用來過濾在mapControl中的點選事件。
2、設計詳細資訊窗體,并對窗體中控件的屬性用代碼指派并綁定
public void showDetails(IFeature pFeature)
{
pfeature = pFeature;
ArrayList arrlist = new ArrayList();
for (int i = 0; i < pFeature.Fields.FieldCount; i++)
{
arrlist.Add(pFeature.get_Value(i));
}
//基本資訊
name = labelname2.Text = arrlist[4].ToString();
IdNo = labelNO2.Text = arrlist[2].ToString();
jhrNo = labeljhr2.Text = arrlist[3].ToString();
sex = labelsex2.Text = arrlist[5].ToString();
birthday = labelbirthady2.Text = arrlist[7].ToString();
adress = textBoxadress1.Text = arrlist[14].ToString();
//殘疾情況
cjtype = labelcjtype2.Text = arrlist[8].ToString();
cjcause = labelcjcause2.Text = arrlist[9].ToString();
cjdescription = textBoxcjdescription1.Text = arrlist[10].ToString();
//康複情況
kfdate = labelkfdata2.Text = arrlist[12].ToString();
kforganization = labelkforganization3.Text = arrlist[11].ToString();
kfdescription = textBoxkfdescription1.Text = arrlist[13].ToString();
//照片
ChildPicAddress = arrlist[15].ToString();
JhrPicAddress = arrlist[16].ToString();
//照片
if (arrlist[15].ToString() == "")
{
pictureBox1.Image = Image.FromFile(@"D:\ZHCL\ZHCL\module\errorpicture\error1.png");
}
if (arrlist[16].ToString() == "")
{
pictureBox2.Image = Image.FromFile(@"D:\ZHCL\ZHCL\module\errorpicture\error1.png");
}
if(arrlist[15].ToString()!=""||arrlist[16].ToString()!="")
{
try
{
pictureBox1.Image = Image.FromFile(arrlist[15].ToString());
pictureBox2.Image = Image.FromFile(arrlist[16].ToString());
}
catch (Exception ex)
{
MessageBox.Show("照片路徑不正确!");
}
}
}
3、在MapControl的點選事件中添加:
if (pMouseOperate == "detail")
{
IMap pMap = axMapControl1.Map;
IActiveView pActiveView = pMap as IActiveView;
IGeometry pGeometry = null;
IEnvelope pEnv;
pEnv = axMapControl1.TrackRectangle();
if (pEnv.IsEmpty == true)//點選
{
tagRECT r;
r.bottom = e.y + 30;
r.top = e.y - 30;
r.left = e.x - 30;
r.right = e.x + 30;
pActiveView.ScreenDisplay.DisplayTransformation.TransformRect(pEnv, ref r,4);
pEnv.SpatialReference = pActiveView.FocusMap.SpatialReference;
}
pGeometry = pEnv as IGeometry;
axMapControl1.Map.SelectByShape(pGeometry, null, false);
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
FormDetail frmdetail1 = new FormDetail();
frmdetail1._CurMap = pMap;
IEnumFeature pEnumFeature = pMap.FeatureSelection as IEnumFeature;
IFeature pFeature = pEnumFeature.Next();
if (pFeature != null)
{
frmdetail1.showDetails(pFeature);
}
frmdetail1.Show();
}
最終效果如圖所示,測試用的,資訊均是瞎填,兒童近照和監護人照片來源于網絡,侵删。