//此接口下找不到事件,方法,属性 换其他接口下查找,或者换父类下查找(帮助和OMD为了简洁有时省略)
//Map下没有adddata事件,Iactiveview下有itemadded事件
private void Form1_Load(object sender, EventArgs e)
{
IMap pmap = this.axMapControl1.Map;
//IActiveViewEvents_Event是事件接口,注意加_Event,Map继承了IActiveViewEvents_Event
//尽量写显式转化,少用隐式转化,不然可能出现莫名其妙的问题
IActiveViewEvents_Event iae;
iae = (IActiveViewEvents_Event)pmap;
iae.ItemAdded += new IActiveViewEvents_ItemAddedEventHandler(map_ItemAdded);
}
//mapcontrol加载数据时触发的方法
void map_ItemAdded(object Item) //需要判断item是什么类型的layer,这就是使用多态必须多出的一步
{
LayerAdded();
}