方法一:
axmapcontrol 自带效果实现:
private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
{
axMapControl1.ShowMapTips = true;
IFeatureLayer pFeatureLayer = axMapControl1.Map.get_Layer(0) as IFeatureLayer;
pFeatureLayer.DisplayField = "Name";
pFeatureLayer.ShowTips = true;
}
方法二:
(效果更佳)C#自带控件
private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
{
IFeatureLayer pFeatureLayer = axMapControl1.Map.get_Layer(0) as IFeatureLayer;
pFeatureLayer.DisplayField = "Name";
pFeatureLayer.ShowTips = true;
string pTip;
pTip = pFeatureLayer.get_TipText(e.mapX, e.mapY, axMapControl1.ActiveView.FullExtent.Width / 10000);
if (pTip != null)
{
toolTip1.SetToolTip(axMapControl1, "名称:" + pTip);
}
else //当 ToolTip 空间显示的内容为 null 的时候,就不会显示了!相当于隐藏了!
{
toolTip1.SetToolTip(axMapControl1, "");
}
}
问题咨询:152702136(QQ群)
技术合作:1044824695