I tried using the following code to listen to the layers loaded into MapControl. However, it is found that the next event is not triggered when the layer is added to the layer group. How do you listen to the layer group to add and delete layers?
mEvent = pAxMapControl.ActiveView.FocusMap as IActiveViewEvents_Event;
mEvent.ItemAdded += new IActiveViewEvents_ItemAddedEventHandler(Event_ItemAdded);
mEvent.ItemDeleted += new IActiveViewEvents_ItemDeletedEventHandler(Event_ItemDeleted);
private void Event_ItemAdded(object Item)
{
if (Item is IFeatureLayer)
{
FeatureLayerAdded(Item as IFeatureLayer);
}
else if (Item is IRasterLayer)
{
RasterLayerAdded(Item as IRasterLayer);
}
else if (Item is ILasDatasetLayer)
{
LasLayerAdded(Item as ILasDatasetLayer);
}
}