1.问题描述
通过以下方式可以很便捷的往选择集内添加要素,但是却无法触发AxMapControl下的OnSelectionChanged事件。
public static void SelectFeatures(IFeatureLayer featureLayer, int[] OIDs)
{
if (pFeatureLayer == null || OIDs == null)
{
return;
}
IFeatureSelection featureSelection = featureLayer as IFeatureSelection;
if (featureSelection != null)
{
IGeoDatabaseBridge2 geoDatabaseBridge2 = new GeoDatabaseHelperClass();
geoDatabaseBridge2.AddList(featureSelection.SelectionSet, ref OIDs);
}
}
2.通过ISelectEvents接口解决
可以通过ISelectEvents接口来解决这个问题,该接口可由IMap接口QI。
ISelectionEvents selectEvents = map as ISelectionEvents;
if (selectEvents != null)
{
selectEvents.SelectionChanged();
}
原文地址:https://www.cnblogs.com/lLazy/p/10662186.html
时间: 2024-11-26 04:39:00